Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can scripts detect the number in number values?

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

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.

0

If i remove the If else then it works. But then it kills all players and detects a random player.

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.