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

how do i make a script start after a button is pressed?

Asked by 3 years ago

so basically i have a gui button and a first person script - how do I make it so you go into first person - from a fixed camera - after you press the button?

they are in seperate scripts

0
Yield it with something like EthanB2151 0 — 3y
0
script.ClickDetector.MouseButton1Down:Connect(function() MrSmartyPants126 0 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

You can do it in 2 steps. 1. Check if the button is clicked 2. Change the camera to first person This is how it looks like in code Put this in a localscript in starterGui


local button = path to the button local Player = game.Players.Localplayer button.Activated:Connect(function() -- checks if the button is touched, if it is, it runs anything inside of the function Player.CameraMode = Enum.CameraMode.LockFirstPerson -- change the camera to first person end)

That should be it!

Reply if there is anything you need more explanation on.

0
What would the path to the button be? would it be game.startergui.menu.frame.imagebutton? Rugrocky 2 — 3y
0
Also it doesnt put me in first person Rugrocky 2 — 3y
0
Let's say you put the localscript inside of the button. The path would be "script.Parent" I reccomend putting the localscript inside of the parent. Game.StarterGui won't work because the starter gui gets replicated to each player, becoming playerGui mariohead13 129 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Yield it with something like

Button.MouseButton1Down:Wait()
0
What does that mean? im new to scripting Rugrocky 2 — 3y

Answer this question