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

I need Help with Remote functions.I want the text lable to say the person's Health.help?

Asked by
Tizzel40 243 Moderation Voter
5 years ago
Edited 5 years ago

hers is the script.I want the text lable to say the character's health I srsly need help with remote functions.................;,

---Local Script


local remotef = game.ReplicatedStorage.ReturnHealth

remotef:InvokeServer()

then the script...

---Script located in workspace


local remotef = game.ReplicatedStorage.ReturnHealth--this is a remote function in replecated storage...


function remotef.OnServerInvoke(plr)
    local char = plr.Character or plr.CharacterAdded:wait()
    return script.Parent.Text == char.Humanoid.Health--i want it to return the health

end

0
What do you need help with, what's the issue. Any errors? = is for setting values, == is for comparing. gullet 471 — 5y
0
I have a text Label and i want the text on it to say my health Tizzel40 243 — 5y
0
I think changing the == to an = should be good, but considering how ur using it here, u might just want to switch it to a remote event (suggestion) Lugical 425 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Simple Solution

---Script located in workspace


local remotef = game.ReplicatedStorage.ReturnHealth--this is a remote function in replecated storage...


function remotef.OnServerInvoke(plr)
    local char = plr.Character --retrieves the character from the player model
    script.Parent.Text = tostring(char.Humanoid.Health) --sets the textlabel's text to the player's health
end

What that script does is set the textlabel's text to the player's health.

0
CAN You explain the tostring? Tizzel40 243 — 5y
0
tostring converts any value to a string, which all it is text, since textlabel's Text property is a string, i have the habit to use tostring to avoid any errors. misiunicholas 50 — 5y
Ad

Answer this question