(Before reading this, please notice I am a horrible scripter as I just started a few months ago)
So I'm trying to do a Ontouched Change TextLabel Text script and I can't figure it out
I'm trying to make it so if you touch a part it changes a text on you're screen. To guide you through the game, and I can't figure it out.
my script is gonna be stupid as I'm still new to scripting
function onTouch(hit) game.workspace.StarterGui.Frame.TextLabel.Text = ("Example") end script.Parent.Touched:connect(onTouch)
workspace.Part.Touched:connect(function(hit) local plr = game.Players:GetPlayerFromCharacter(hit.Parent) plr.PlayerGui.ScreenGui.Frame.TextLabel.Text = "adasdasda" end)
change first line to whatever your part is change the last line to whatever your things are called and it should work
Hello, ment34591!
I think i know how to solve your problem!
A gui is on the "StarterGui" to be added to new players that join, if the player is already on the game, you have to acces player's gui object =D
This script will change the text of the player that touched!
function onTouch(hit) if game.Players:FindFirstChild(hit.Parent.Name) then game.Players[hit.Parent.Name].PlayerGui.Frame.TextLabel.Text = "Example" end end script.Parent.Touched:connect(onTouch)
This one will change the gui of all players
function onTouch(hit) for i,plr in pairs(game.Players:GetChildren) do game.Players[plr.Name].PlayerGui.Frame.TextLabel.Text = "Example" end end script.Parent.Touched:connect(onTouch)
Hope this helps
Good Luck with your games!