✓ Accepted answer
doing a loop like that without a wait can crash your game
and you forgot to put another end) in the end of your script
with fixes:
game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(char)
while true do wait(0.35)
script.Parent.Text = char:WaitForChild("Humanoid").Health
end
end)
end)
also using a loop for every player that comes is not very good and can still lag the server but
i dont think the server can detect when a player's humanoid is changed so in a localscript you can instead do:
local hum = game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid")
hum.Changed:Connect(function(property)
if property == "Health_XML" or property == "Health" then
script.Parent.Text = hum.Health
end
end)