Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Send the player's health to client with a remote function?

Asked by
TofuBytes 500 Moderation Voter
10 years ago

I need help on how I send the player's health to their client GUI from the server script. I already wrote up the client-side script, but I need help on how to send it from server-side. Any help?

Server:

function game.ReplicatedStorage.PlayerHealth.OnServerInvoke(player)
local health = player.Character:WaitForChild("Humanoid")
--Unsure of what to do here.
end

Client (If needed to test):

local Health = script.Parent.Parent.Parent.Parent.Character.Humanoid

while true do
game.ReplicatedStorage.PlayerHealth:InvokeServer()
PlayerHealth = Health.Health
PlayerMaxHealth = Health.MaxHealth
wait(.1)
script.Parent.Text = (math.floor(PlayerHealth) .. " / " .. math.floor(PlayerMaxHealth) )
wait(.1)
end

Answer this question