function talk(plr) if plr:GetRankInGroup(1056046) >= 7 then local Msg = Instance.new("Hint", workspace) Msg.Text = "One Krabby Patty, please." Msg:remove() end end script.Parent.MouseButton1Up:connect(talk)
The script is inside a surface gui on a brick... And the parent of the button is a frame, the final parent is a surface gui. So the scripts parent is the button.
Might of confused you there....
This is a regular script inside a Textbutton. Every time I click the GUI, it says:
attempt to index local 'plr' (a number value)
What's wrong with it?
Help me...
So, I took a look at the SurfaceGUI wiki page. It says that "SurfaceGUIs must be a descendant of PlayerGUI in order to know the player who is interacting with it"
What this means is you must put the SurfaceGUI in the StarterGUI to find what player is interacting with it. SurfaceGUIs cannot find the interacting player on their own. You likely have an instance called a TextButton that runs the script, so this is going upon this inference.
You may be asking "But how will this show up in the workspace then?"
The answer is that you must set the adornee of the SurfaceGUI to the part that you want the SurfaceGUI to appear on. You need a localscript inside the SurfaceGUI that contains your previous code and mine:
For example:
local plr = game.Players.LocalPlayer Player:WaitForChild(Character) wait(1) script.Parent.Adornee = game.Workspace.YourPartName script.Parent.TextButton.MouseButton1Click:connect(function() -- Your code inside a function that runs when someone clicks the textbutton function talk(plr) if plr:GetRankInGroup(1056046) >= 7 then local Msg = Instance.new("Hint", workspace) Msg.Text = "One Krabby Patty, please." Msg:remove() end end end)
I hope this works, and helps.