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

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

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

2 comments

0

Yield it with something like

0

script.ClickDetector.MouseButton1Down:Connect(function()

2 answers

✓ Accepted answer

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.

3 comments

0

What would the path to the button be? would it be game.startergui.menu.frame.imagebutton?

0

Also it doesnt put me in first person

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

Yield it with something like

Button.MouseButton1Down:Wait()

1 comment

0

What does that mean? im new to scripting

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