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 Change The Camera By Clicking A Gui?

i want to make it so when the player clicks a button inside a frame it then changes the camera. i am using this script:

repeat wait() until Player.Character

Camera.CameraType = "Scriptable" Camera.CFrame = game.Workspace.CamPart.CFrame

script.Parent.Enabled = true

to set the camera to a part when you join the game. i want it to do the same thing but it activates not when you join the game but when you click a button in a frame inside a gui in starter gui.. thank you for any help you can provide

6 comments

0

Watch a tutorial on that.

0

i cant find one

0

And if the video is not enough, watch the next part

0

We need more info, if you don't provide then take down the question please.

0

i have gave as much info as i have

1 answer

✓ Accepted answer

You didn't script the part where a player has to click a button in order for the code to execute. You said you wanted the GUI to be visible though when a player clicks the button.

game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.ButtonName.MouseButton1Click:Connect(function() -- button has to be whatever the player is supposed to click
	game.Workspace.Camera.CameraType = "Scriptable"
	game.Workspace.Camera.CFrame = game.Workspace.CamPart.CFrame

	script.Parent.Enabled = true
end)

4 comments

0

didnt work

0

Did you refer to the button in PlayerGui or StarterGui? You did say it wasn't working in StarterGui, so I'm not sure if you used StarterGui instead of PlayerGui.

0

I edited the script to show you how you're supposed to reference it. If you reference the GUI in StarterGui, it won't work because StarterGui only clones the GUI when the player joins or resets. However, you can change up the PlayerGui because it's what the player is currently seeing on their screen. Also make sure this is in a LocalScript.

0

It worked thanks

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