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

Turn a instance into a string or?

Hey, this is my first post and I'm just simply trying to learn why this line of code requires a string and if I can get it to take a variable/instance.

All I'm doing is trying to make a sign change to the player's name when touched.

I do understand that this code does have some stuff that could be shed off but I still can't find out why it wouldn't work.

The line of code I'm having trouble with is

"ourSign.Text = character"

My full code:

local sec15 = script.Parent

local platformg = false

local ourSign = game.Workspace.oursign.SurfaceGui.TextLabel

local function onTouch(partTouched)

local character = partTouched.parent

local humanoid = character:FindFirstChildWhichIsA("Humanoid")	


if character and platformg == false then
	ourSign.Text = character
	platformg = true
end

end

--Event sec15.Touched:Connect(onTouch)

1 answer

✓ Accepted answer

Alright so here's what you've got wrong.


if character and platformg == false then
    --print ("A Humanoid is on me")
    ourSign.Text = character.Name --you want  to set the text to the name of the character, not the character itself!
    platformg = true
end

--print ("Character")
--print (character)

Basically if you try to set a string value to an object value it's not going to work, you want to use the character name (which is a string value) which you can retrieve using Character.Name

Hope this helps ;)

1 comment

0

Not exactly sure what all the prints are about, or if i even put them there..

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