I have a script to change the settings of the Health/Name display of a character.
I tested it with two people, but it didn't work.
Here is the script:
HealthShown = false NameShown = true function name(plr) if NameShown == true then plr.NameDisplayDistance = 100 if NameShown == false then plr.NameDisplayDistance = 0 end end end game.Players.PlayerAdded:connect(name) function health(player) if HealthShown == true then player.HealthDisplayDistance = 100 if HealthShown == false then player.HealthDisplayDistance = 0 end end end game.Players.PlayerAdded:connect(health)
What makes this not work?
Your if statements have the end
in the wrong place. In order for HealthShown==false
to be checked HealthShown
must have already been true. To fix this we can move the end
or change it to an else
and remove the end
. Also you do not need the == true
. Finally there is no reason to have multiple event connections.
This is a localscript
make sure to Place it in StarterGui
.
HealthShown = false NameShown = true function name(plr) if NameShown then plr.NameDisplayDistance = 100 else plr.NameDisplayDistance = 0 end end function health(player) if HealthShown then player.HealthDisplayDistance = 100 else player.HealthDisplayDistance = 0 end name(player) end wait(0) health(Game.Players.LocalPlayer)