So I have a Button that when you click it I want it to change the players Gui from Unemployed to Cashier. It is not working and I can't figure out why. Any help? Here is what I got:
function onClicked(player) game.player.PlayerGui.Job.Jobname.Text = "Cashier" end script.Parent.ClickDetector.mouseClick:connect(OnClicked)
P.S It is not in a local script, just an ordinary one. And this script is inside the Brick that you click.
Little typo on the connection statement;
'...ClickDetector.mouseClick'
also you're identifying the player wrong;
'game.player' --parameter 'player' leads directly to the player value
And lastly, your function name and calling has to match;
'function onClicked(player)', '...:connect(OnClicked)'
Try this;
script.Parent.ClickDetector.MouseClick:connect(function(player) player.PlayerGui.Job.Jobname.Text = "Cashier" end)
function onClicked(player) --player is already a variable here, you do not need game. at the beginning of the next line. player:WaitForChild("PlayerGui").Job.Jobname.Text = "Cashier" --The wait for child is just making sure PlayerGui exists. end script.Parent.ClickDetector.MouseClick:connect(onClicked) --I am not sure if MouseClick is case sensitive, but I modified it anyways. --And you are calling the wrong function. Lua IS CASE SENSITIVE! --The script was looking for OnClicked when you only have onClicked