#Need ideas for practice with tables

92 messages · Page 1 of 1 (latest)

karmic basin
#

A button that any player in the game can push, but each player gets an individual cooldown of 5 seconds. The button kicks a random amount of players from the server between 1 and half the number of current players. The last player standing wins ;)

#

Restrictions: One server-sided script, one button, one ClickDetector

red frigate
red frigate
#

I can do either, just wondering the specifics.

red frigate
red frigate
# karmic basin Strictly server-sided

Well, I've got everything besides kicking between 1 and half the number of players. Right now, it just kicks a random player. Gonna have to work on that a while longer, can't figure out how to take what I get from math.random and find every player's index & value from 1 to that given value, then put that into a diff table.

red frigate
strange summitBOT
#

studio** You are now Level 2! **studio

red frigate
#

I am on the right track here, I now have it list every number between 1 and the number of players in the server and put those values into the KickedPlayers table.

#

But I put numbers in rather than the player instances, therefore I can't do the actual kicking. So what I want to do now is take those values I get and go through AllPlayers, taking the value of any indexes that match the ones in KickedPlayers and then kicking those values, which will be playerinstances.

#

Which I am currently trying to figure out...lol.

#

Just placeholder prints in there atm.

#

WAIT

#

I THINK I DID IT

#

IM PRETTY SURE I DID IT

#

Fixed code below

patent vigil
#

Is that... Chat GPT?

#

(or any other AI)

red frigate
#

Is it that bad???

#

I added the explanation so that Ziffix could read it and understand my thinking.

#

And to help me piece together what I was trying to do.

patent vigil
#

Oh sorry then, but when I see that many lines with comment, I'm used to assume that it was made with ChatGPT...

red frigate
#

Plus, I'm not used to tables, so I figured it's better for me to learn when I outline everything I think I'm doing with the script.

#

That way, if I mess up, I can correct the thinking.

#

And I can see what I had a misconception about.

patent vigil
#

One problem I see is nesting a lot

#

By doing something like:

if ... then
   if ... then
        for .... do
            if ... then
                for ... do
red frigate
#

Yeah, but I was forced to keep it all on one server script, and I don't know how else to do it.

patent vigil
#

You instead could use function and use fewer if

red frigate
#

Ah, gotcha.

#

Will it still work though?

#

I'm getting a friend on to test it right now.

patent vigil
#

If you do it right, yea

red frigate
#

No, I mean what I have now.

#

I get that it's inefficient, but I just want it to work atm. I can improve it later.

patent vigil
#

You can test in Roblox Studio with multiple "players"

red frigate
#

We'll do multiple runs to make sure it all goes according to plan.

patent vigil
#

This is weird...
You are checking what you did a line above
Thats like creating a variable local x = true and checking if x == true a line under...

red frigate
strange summitBOT
#

studio** You are now Level 3! **studio

red frigate
#

Well, I just ran 4 tests, and it kicked both of us all four times.

#

Not sure if that's a statistical anomaly or what.

#

Gonna recheck my code.

#

I'm not sure where it would be...

#

Maybe I need to...

#

Wait I have an idea.

patent vigil
#

Can you send the code? I would like to test it and improve it

red frigate
#

Like I said, I ran it 4 times and it kicked both of us every time, so I either messed up or, statistically, I got unlucky.

karmic basin
#

There should always be one player left in-game

#

I'm happy to see that you put your head to this problem

#

Unfortunately, there's a lot going on in your script, so I can't comment on it effectively. Would you like to see my solution to the problem tomorrow?

red frigate
karmic basin
#

R.I.P

red frigate
#

Like, I get nobody really wins, but is the cooldown going to work for each individual and will not everyone be kicked every time ?

#

Those are the only two questions I have that I can’t definitively answer since I can’t round up enough people to try it atm.

karmic basin
#

You took an interesting approach to the problem. It's unique, so I'll have to sit down with your code to tell you more. I'm about to head offline myself, so let's leave this for tomorrow

red frigate
#

That works for me.

karmic basin
#

I'll do a live coding session for my solution so you can follow along

red frigate
red frigate
#

Awesome 👍

karmic basin
#

For reference, it's 1:28 AM for me

red frigate
#

2:28 for me, so I’ll keep that in mind.

karmic basin
#

👌

karmic basin
#

@red frigate, you online?

red frigate
# karmic basin <@1060832936036945950>, you online?

Just got back home, they needed me on overtime to finish up the removal. Friend of mine offered to cover dinner so I gotta do that and then I’ll be coming back, so I’ll message you when things are taken care of. If you aren’t online when I’m ready, don’t sweat it, we’ll figure it out 👍

#

Also, I just accidentally found the error in my script. I was going over it in my brain at work, and I figured out what the issue was.

karmic basin
red frigate
karmic basin
#

Works for me

red frigate
#

Currently making a slight edit to my code to fix what was wrong

#

Fixed.

karmic basin
#

Alright, let's hop on a call

#

#1004892175449989260

#

@red frigate

red frigate
#

Alr.

#

@karmic basin can you hear me?

#

One moment.

#

It says I'm connected, and I reset the voice commands, it's not going through???

#

Yeah, PC.