script:
local textbutton = script.Parent
textbutton.MouseButton1Click:Connect(function(onclicked)
print("working")
end)
You need to put the SufaceGui inside your PlayerGui then set the Adornee of SurfaceGui to the part in the workspace.
like this?
script:
local plr = game.Players.LocalPlayer
playerGui = plr.PlayerGui
local textbutton = script.Parent
local surface = game.Workspace.Part:FindFirstChild("SurfaceGui")
surface.Parent = playerGui
textbutton.MouseButton1Click:Connect(function(onclicked)
print("working")
end)
Your original script is fine, just remove the “onclicked” parameter from the function.
You just need to change the script from a local one to a server script (as this is a SurfaceGui parented to the workspace).