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

How do I make a textlabel change when I step on an item?

I have put a TouchInterest and a script inside of a tool that you can pick up.

I want it so that when you pick this tool up, a textlabel changes (it is located: StarterGui > BtmText > Frame > TextLabel )

The code currently doesn't work and I need help with it.

The code right now:

function onTouched(hit)

wait(.5)
game.StarterGui.BtmText.Frame.TextLabel.Text = "You picked a keycard up!"

end

script.Parent.Parent.Touched:connect(onTouched)

Thanks

  • Frosty

1 comment

0

Oh also, picking up the item does work but I just need help with the changing of the textlabel :)

1 answer

When you touch an object, you would need to fire a RemoteEvent to the client who stepped on it. And then have a Local Script change the TextLabel to your desired text.

This might get you started...

function onTouched(obj)
	local character = obj.Parent
	local humanoid = obj.Parent:FindFirstChild("Humanoid")
	
	if humanoid then
		local player = game.Players:GetPlayerFromCharacter(character)
		-- FireEvent(player)
	end
	
end
script.Parent.Parent.Touched:Connect(onTouched)

https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

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