Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Surface GUI script not responding to buttonclicks?

Asked by 3 years ago

Please help! I am making a surface GUI textbutton, and for some reason, the code is not working/responding to mouse clicks. Here is my code:

1local button = script.Parent
2local function onButtonActivated()
3    print("gui authenticated")
4end
5 
6button.Activated:Connect(onButtonActivated)
0
try button.MouseButton1Click:Connect(onButtonActivated) ? NGC4637 602 — 3y
0
But its not activated its for tools. Try using MouseButton1Click instead. acediamondn123 147 — 3y
0
none of this works. it just does not respond. i do not know why. danielminecrafter66 18 — 3y
0
Nevermind(i was being dumb) i fixed it! Thanks' for the help! danielminecrafter66 18 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

The reason is because you must have the Surface gui in the playerGui and have the adornee set to the part that you want the surface gui to be on. I believe it is safe to assume that you have the SurfaceGui in the part itself.

What you want to do is make sure the SurfaceGui parent is set to the player's playerGui. Like shown here (The starterGui, where it will end up in the playerGui)

Then, in your script. make sure the SurfaceGui's Adornee. Like shown here is set to the part that you want the surface gui to be shown on.

So you'll want your final code to look something like this:

1local screenGui = script.Parent    -- or however you have this set lol
2local button = screenGui.TextButton
3local function OnButtonActivated()
4    print("Gui Authenticated!")
5end
6 
7screenGui.Adornee = workspace.Part
8 
9button.Activated:Connect(OnButtonActivated)

Hope this helps :)

Ad
Log in to vote
0
Answered by 3 years ago

image link:

1local guithing = script.parent.parent
2local button = guithing.TextButton
3button.MouseButton1Click:Connect(function()
4    print("yeet")
5end)
6 
7guithing.Adornee = workspace.tvscreencpp

Answer this question