I understand that if you click a brick with the function
script.Parent.ClickDetector:connect(function(p)
player = p.Parent
end)
But how would I get player in a textbutton on a surfacegui? I can't work it out. Thanks.
I understand that if you click a brick with the function
script.Parent.ClickDetector:connect(function(p)
player = p.Parent
end)
But how would I get player in a textbutton on a surfacegui? I can't work it out. Thanks.
For a surface gui it would have to be a local script put in starterpack/startergui. So we will be able to use localplayer. Example:
local textbutton = workspace.Part.SurfaceGui.TextButton
textbutton.MouseButton1Click:connect(function()
print(game.Players.LocalPlayer)
plr = game.Players.LocalPlayer
end)
That should work, hope it helped!
This discussion is preserved as it was. New answers, comments, and votes are closed.
8 comments
No, because the script is inside the surfacegui.
What do you mean the script is inside the surfacegui, when the button is clicked, you can get the localplayer from the local script that you put in starterpack/startergui, and if you need that player in a serverscript, then you can use RemoteEvents... that's the only way it's possible.
The script is inside the surfacegui. What's so confusing about that? And I don't want the script in StarterPack/GUI. It needs to be in that part for that model.
Invite me to a party on roblox, so I can better explain...
@Traigla, this is the only way you can get it, and if you want to do anything with the script that is going to be under the brick, that would be a server script, and you can send information to that from the local script using a RemoteEvent, abs is totally right.
You need to adornee the surface GUI to the actual part, but keep the real Gui inside the player
I think triagla is pointing out that the local script is under the brick or surfacegui, and it isn't getting put into the player in game.Players
Thats why you have to do what I said earlier, @dragon