Problem with Values

Basically, i have a value inside a player, and if that value reaches 0, the player dies.

The problem is when the player respawns the value stays 0 even when i use a script with player.CharacterAdded to set the value back to max.

Does anyone know how i can fix this?

I’m pretty sure its player.CharacterAdded

Yeah, that’s what i used, sorry for typing it wrong here.

Where exactly is the value located, inside the player right?

and if we could can you send the code that changes this value?

1 Like

Yes, what i tried to do is

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
               plr.Value.Value = 135
	end)
end)

You should instead set the value back to 135 when you detected the value is 0, so instead

game.Players.PlayerAdded:Connect(function(plr)
  local value = plr:WaitForChild("Value")
  value.Changed:Connect(function(x)
    if x <= 0 and plr.Character then
       plr.Character:BreakJoints()
       value.Value = 135
    end
  end)
end)

or something along those lines, since you never know which happens first if you were to do it separately

3 Likes

Found a way to do it using that