Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can scripts detect the number in number values?

Asked by 9 years ago

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

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

1 answer

Log in to vote
0
Answered by
drew1017 330 Moderation Voter
9 years ago

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.

Ad

Answer this question