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

How Do I Change The Camera By Clicking A Gui?

Asked by 4 years ago
Edited 4 years ago

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

0
Watch a tutorial on that. User#34929 0 — 4y
0
i cant find one ErraticThe_legend27 8 — 4y
0
And if the video is not enough, watch the next part User#34929 0 — 4y
View all comments (2 more)
0
We need more info, if you don't provide then take down the question please. MrTrayLot 2 — 4y
0
i have gave as much info as i have ErraticThe_legend27 8 — 4y

1 answer

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

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)
0
didnt work ErraticThe_legend27 8 — 4y
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. AntiWorldliness 868 — 4y
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. AntiWorldliness 868 — 4y
0
It worked thanks ErraticThe_legend27 8 — 4y
Ad

Answer this question