Hello, this is easy, i made a script but i see nothing wrong with it, but i dont see the textlabel changing text :(
StarterGui(folder) Health(ScreenGui) health(TextLabel) healthcheck(normal Script)
the healthcheck script:
while true do script.Parent.Text = script.Parent.Parent.Parent.Parent.Character.Humanoid.Health wait(1) end
why this no work? parent of that is health, perent of that is Health, parent of that is StarterGui, last .Parent is Parent of StarterGui, which when playing, is the Player, then Character is its character then humnaoid then health, i see no errors, but why doesnt it set the variable when i damage myself by touching a testbrick i made that takes away 50 health? the health take away thing works, for the default health bar, but the number for textlabel doesnt show health! By the way right now im more focused on number and i dont care about rounding it to a whole number... please help
"Normal" (server) scripts do not run in PlayerGui. This was possible with experimental mode, however experimental mode has been removed and this is now no longer possible.
The fix is easy:
The server has absolutely no reason to be inside a GUI. In addition, you should use the humanoid.HealthChanged
event instead of a while loop. The codes only need to run when the health changes, not every second.
Also use LocalPlayer
rather than crap tons of script.Parent
local client = game:GetService("Players").LocalPlayer local humanoid = (client.Character or client.CharacterAdded:Wait()):WaitForChild("Humanoid") humanoid.HealthChanged:Connect(function(health) script.Parent.Text = tostring(health) end
health
is the new health of the humanoid.
Local Script within StarterGui
local player = game.Players.LocalPlayer while true do if player.Character ~= nil and player.Character:FindFirstChild("Humanoid") ~= nil then script.Parent.Text = player.Character.Humanoid.Health end wait(1) end
The main issue with the script is that there is no wait time and since the player character doesn't load at the same time as the server, then there is no character or humanoid to check the health of.
Within the loop, you can check if there is a character and humanoid before causing the change in the textlabel as shown above.