Whenever a player joins the game, the code below successfully adds a bool value and sets it to true, and the rest of the code is supposed to print whenever the value of the bool is changed. However, it's not printing anything.
local Player = game:GetService("Players")
function onPlayerAdded(player)
local bool = Instance.new("BoolValue", player)
bool.Name = "AliveStatus"
bool.Value = 1
print('Welcome, ' .. player.Name)
end
game.Players.PlayerAdded:connect(onPlayerAdded)
while true do
wait(1)
for i,v in pairs(game.Players:GetChildren()) do
status = v.AliveStatus
print(v.Name)
status.Changed:connect(function()
if(status.Value == 1) then
print('yes')
end
if(status.Value == 0) then
print('no')
end
end)
status.Value = 0
end
end
I'm not really sure what the problem is, any help is appreciated.
p.s. there are no errors, and the script does seem to run fine, as it prints the users name every second like it's supposed to, which makes me think it's running through the whole function, the changed event just isn't working :s
Cheers. -Almorpheus

2 comments
Thanks! Worked perfectly.
No problem.