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

GUI text button not working. Any Advice?

Asked by 10 years ago

I have been baffled by this for a week by now. I have been trying to make a text button on a GUI to work. There isn't any issue as far as I can see, and cross referencing with the wiki's hasn't helped. The button is supposed to make the camera follow a separate block. Although the camera code works the button hasn't worked once. Any Help is appreciated, thanks.

local Button = WOORK -- Button name

function Onclick(part)
local target = Workspace.BattleShip.BCameraBlock-- Beginning working part of camera
local camera = Workspace.CurrentCamera
camera.CameraType = "Follow"
camera.CameraSubject = target
camera.CameraMinZoomDistance= 5
Camera.CameraMaxZoomDistance= 10 -- end of working part of camera
end


Onclick(Button.MouseButton1Click) 

1 answer

Log in to vote
1
Answered by
Validark 1580 Snack Break Moderation Voter
10 years ago

At the end of the script you put:

Onclick(Button.MouseButton1Click)

What that does is it runs the function Onclick for Button.MouseButton1Click as the part. You should have this at the end:

Button.MouseButton1Click:connect(onClick)

That will connect to the Onclick function when Button is clicked.

Make sure Button is referenced in the script as script.Parent or something.

0
This helped a lot! thanks. soldier2720 5 — 10y
Ad

Answer this question