You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
i made a role choosing script where it puts players in innocent table then one player is chosen to be sherrif and they will be removed from innocent table and the same happens to murderer -
What is the issue? Include screenshots / videos if possible!
when i ran this script. the innocent table doesnt have anything removed at all. (look in screenshot) (im testing 3 players)
i had table remove but it doesnt work at all
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
yes i looked but there’s no topic related to this
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
here’s my script (i added comments)
local players = game:GetService("Players")
local run = game:GetService("RunService")
local function rungame()
local innocents = {}
local murderers = {}
local sherrifs = {}
local plys = players:GetPlayers()
if #plys >= 3 then
innocents = plys
local chosen_murderer = math.random(1, #innocents) --selects a random innocent
murderers[#murderers+1] = innocents[chosen_murderer] --adds the innocent to that table
table.remove(innocents, chosen_murderer) --should remove the innocent from the innocent table
local chosen_sherrif = math.random(1, #innocents) --selects a random innocent
sherrifs[#sherrifs+1] = innocents[chosen_sherrif] --adds the innocent to that table
table.remove(innocents, chosen_sherrif) --should remove the innocent from the innocent table
local spawnlings = innocents
for i, v in pairs(sherrifs) do spawnlings[#spawnlings+1] = v end
for i, v in pairs(murderers) do spawnlings[#spawnlings+1] = v end
for i, v:Player in pairs(spawnlings) do
v:LoadCharacter()
end
print(innocents) --should be one but it stayed the same as before??
print(murderers) --one
print(sherrifs) --one
print(#innocents+#murderers+#sherrifs) --It counts to 5 wth?????
else
return
end
local roundtime = 5*60
local elapsedtime = 0
repeat
local dt = run.Heartbeat:Wait()
elapsedtime += dt
--print(innocents)
until (#murderers == 0) or ((#innocents + #sherrifs) == 0) or (elapsedtime >= roundtime)
local results = {murderers,innocents,sherrifs}
print(results)
return results
end
any help is appreciated!
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.