Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

GUI text button not working. Any Advice?

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

✓ Accepted answer

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.

1 comment

0

This helped a lot! thanks.

This discussion is preserved as it was. New answers, comments, and votes are closed.