I am trying to give everyone a target and a person targeting them, so person a might be targeting person b but is being targeted by person c. I have tried this, I do not believe it will work, but I can't test it in studio, because it requires multiple people. I have a problem because what if person a's target is person b and person b's target is person a and there are only 3 people in the server, person C will have no one to target. I can't make it so you can't target your hunter otherwise the final two won't be able to hurt each other. This is my script:
--[[Values]] --[[Tables]] Players = game.Players:GetChildren() -- Table of players --[[Checking alive players]] if player.TeamColor ~= "Grey" then Colours = { BrickColor.new("Sand red"), BrickColor.new("Sand blue"), BrickColor.new("Sand green"), BrickColor.new("New yeller"), BrickColor.new("Br. yellowish orange"), BrickColor.new("Lavender"), BrickColor.new("Dusty Rose"), BrickColor.new("Deep blue") } --[[Colouring]] function Assign() for a = 1, Players do a.Character.Parent.Torso.BrickColor = Colours[a] end end --[[Current players (The players still alive)]] function Alive() Current = Players for i in Current do if i.TeamColor ~= "Grey" then Current.remove(i)-- No idea how to use this end end if #Current == 1 then Win() elseif #Current == 0 then Target() -- Start again end end --[[Selecting Hunters/Targets]] function Select() b = Players[math.random(1, Current)] -- Random player if a ~= b and a. Target == nil then a.Target.Value = b.Name b.Hunter.Value = a.Name print (a.."/'s target is:"..b) print (b.."\'s hunter is:"..a) elseif a == b then Select() end end --[[Win]] function Win() print (Current[1].." won!") Target() end --[[Target, Hunter]] function Target() Assign() Alive() for a = 1, Current do Select() end end wait(5) Target()
Line 3.
You want to put that in a loop, otherwise it'd only be the first person that joined. Try making a PlayerAdded function and then assign the variable in the function.
edit:
--[[Colouring]] 20 function Assign() 21 for a = 1, #Players do --add a hashtag to get the amount of stuff in a table. You originally had Players 22 a.Character.Parent.Torso.BrickColor = Colours[a] 23 end 24 end