I’ve been trying to make a script that does the following: When player touches a GUI, I want their camera/view to face towards what is infront of the part (aka the stage) and when they click the GUI again their camera/view reverts back to their normal player view
Here is an example;
Can anyone help me make this? Thanks to anyone who can help by providing it.
I’m confused… in the video, you’re the one doing the example. It looks like you already made it? But anyway, when you click the GUI, you should make a script to tween the player’s camera to where you want (after setting CameraType to Scriptable), and when you click it again, tween the camera back to the player, and make the CameraType set to Custom.
--> this is a local script, in a ScreenGUI
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local button = script.Parent.Button
local looking = false
local endCFrame = CFrame.new() --> put the CFrame of where you want the camera to end up here
local tweentime = 3
local debouncetime = 0.5
local active = false
button.MouseButton1Click:Connect(function()
if active then return end active = true
looking = not looking
if looking then
camera.CameraType = Enum.CameraType.Scriptable
game.TweenService:Create(camera, TweenInfo.new(tweentime, Enum.EasingStyle.Sine, Enum.EasingDirection.Out,0,false,0), {CFrame = endCFrame}):Play()
wait(tweentime+debouncetime)
else
camera.CameraType = Enum.CameraType.Custom
wait(debouncetime)
end
active = false
end)
I tested it in one of my games, and it seems to be working. You just need to add where you want the camera to end up, and make sure you have a button called Button in a ScreenGui. https://gyazo.com/ae9f70b5cbc26103db665ccdf66112ca
CFrame… how do I find this?
Sorry for asking lots of questions, I’m new to scripting and am trying to learn and this helps as I always review the scripts.
I can’t really explain what CFrame is, but it basically determines a BasePart’s Position and Orientation. CFrame includes alot of handy functions for different situations. To get a BasePart’s CFrame, you can say Part.CFrame (a hidden property).