So I made a SurfaceGui and I want to make it so the TextButton can only be clicked by me. How would I do that?
local part = Instance.new("Part", workspace) part.Size = Vector3.new(50,50,4) local screen = Instance.new("SurfaceGui", part) local frame = Instance.new("Frame", screen) frame.Size = UDim2.new(1,0,1,0) frame.Style = "DropShadow" wait(-.1000) local button = Instance.new("TextButton", screen) button.Size = UDim2.new(.5,0,.5,0) button.Position = UDim2.new(.25,0,.25,0) button.Style = "RobloxRoundButton" button.MouseButton1Down:connect(function() print "Clicked!" --But how do I make it so only I Can click it and not other players? end)
Thanks.
local player = game.Players.LocalPlayer local part = Instance.new("Part", workspace) part.Size = Vector3.new(50,50,4) local screen = Instance.new("SurfaceGui", part) local frame = Instance.new("Frame", screen) frame.Size = UDim2.new(1,0,1,0) frame.Style = "DropShadow" wait(-.1000) local button = Instance.new("TextButton", screen) button.Size = UDim2.new(.5,0,.5,0) button.Position = UDim2.new(.25,0,.25,0) button.Style = "RobloxRoundButton" button.MouseButton1Down:connect(function() if player.Name == "silverminer226" then print("Clicked") end end)
For this to work, you are gonna need to put the SurfaceGui into StarterGui, so you can get the LocalPlayer
Now you need to Adornee the GUI, so it's parent is then the block it is on. As I do not know what block and where it is, I can not set the Adornee
, but the wiki will show you how to do it.