Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

3 comments

0

What do you need help with, what's the issue. Any errors? = is for setting values, == is for comparing.

0

I have a text Label and i want the text on it to say my health

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)

1 answer

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.

2 comments

0

CAN You explain the tostring?

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.