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

TextButton script in Surface GUI are not activating, any ideas?

Asked by 4 years ago

Ok, so in in the workspace I have a HingeConstraint and 3 surface GUIs. The surface GUIs are all in one part. The following script is inside one of the TextButtons. The script is NOT a localscript.

local drawhinge = game.Workspace.Walls.Gatehouse.Draw.HingeConstraint --Path to HingeConstraint

local close = script.Parent.Parent.Parent.Close.Close --Path to other TextButton
local open = script.Parent --Path to this TextButton
local statusbar = script.Parent.Parent.Parent.SurfaceGui.statusbar --Path to statusbar textlabel


script.Parent.Activated:Connect(function() --Connect on Activation
    print("Activated")--Check if it activated
    print("Opening")--Indicate that drawbridge is opening
    close.Visible = false --Make other textbutton invisible so it cant be clicked
    drawhinge.AngularVelocity = drawhinge.AngularVelocity - 5 --Open drawbridge
    statusbar.Text = "Opening..." --Make the status bar indicate that the drawbridge is opening
    wait(4)--Wait for it to open
    drawhinge.AngularVelocity = 0 --Stop opening Drawbridge
    close.Visible = true --Make other textbutton visible again
    statusbar.Text = "Open" --Make the status bar indicate that the drawbridge is open
    print("Open")--State that the drawbridge is open
end)

When i go in output and test it out, not even the print("activated") function runs. It seems that the textbutton function isn't activating when i click it, and i dont know why.

1 answer

Log in to vote
0
Answered by 4 years ago

Is "script.Parent" the textbutton? Because from what I know the event when a textbutton is clicked is .MouseButton1Click. So the script will be like:

local drawhinge = game.Workspace.Walls.Gatehouse.Draw.HingeConstraint --Path to HingeConstraint

local close = script.Parent.Parent.Parent.Close.Close --Path to other TextButton
local open = script.Parent --Path to this TextButton
local statusbar = script.Parent.Parent.Parent.SurfaceGui.statusbar --Path to statusbar textlabel


script.Parent.MouseButton1Click:Connect(function() --Connect on Activation
    print("Activated")--Check if it activated
    print("Opening")--Indicate that drawbridge is opening
    close.Visible = false --Make other textbutton invisible so it cant be clicked
    drawhinge.AngularVelocity = drawhinge.AngularVelocity - 5 --Open drawbridge
    statusbar.Text = "Opening..." --Make the status bar indicate that the drawbridge is opening
    wait(4)--Wait for it to open
    drawhinge.AngularVelocity = 0 --Stop opening Drawbridge
    close.Visible = true --Make other textbutton visible again
    statusbar.Text = "Open" --Make the status bar indicate that the drawbridge is open
    print("Open")--State that the drawbridge is open
end)
0
yes the textbutton is script.parent sergeant_ranger 184 — 4y
Ad

Answer this question