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

2 comments
Well, is some of it working, or is the entire thing not functioning? We'll need to know what the exact issue here is.
If i remove the If else then it works. But then it kills all players and detects a random player.