I am writing a script for a game i am making and i have run into a problem. I have an if then statement that suppose to see if a number value is ether 1 or 2. If it is 1, it detects a random player. If the number is 2, it kills all players. But it does not seem to do that. I would like help with my script please :P.
value = script.Value if value == 1 then local Plrs = game.Players:GetPlayers() Plr1 = Plrs[math.random(1,#Plrs)] print(Plr1) elseif value == 2 then --Kill all players after 5 Min to end game for i, player in ipairs(game.Players:GetPlayers()) do if player.Character then local hum = player.Character:FindFirstChild('Humanoid') if hum then hum.Health = 0 end end end end
The Value object isn't a value itself; The actual value it holds is in a property called Value.
Value = script.Value.Value, however, wont work either, as script's cant hold variables of a Value property. So if value.Value == 2 should work.