why is it a serverscript, change it to a localscript and instead of using many parents to refer to the humanoid just do it like so
local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Char:WaitForChild("Humanoid")
Humanoid.HealthChanged:Connect(function()
script.Parent.Size = UDim2.new(1, 0, Humanoid.Health / Humanoid.MaxHealth , 0)
end)
Convert it to a local script THEN use a :FireServer to call the health change to the server to make it visible to everybody else. We can get the script from @ayoub50 and change it a bit
local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Char:WaitForChild("Humanoid")
local RemoteEvent = remoteevent
Humanoid.HealthChanged:Connect(function()
RemoteEvent:FireServer(Humanoid.Health)
end)