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

How do I cause the camera to return to normal on mouseclick?

Asked by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

I'm using a script which fixes the camera at a certain location, and all works well with that. What I don't know, though, is how to return the camera to normal when the start button is pressed. How would this be achieved? Thanks in advance.

The script:

local cam = workspace.CurrentCamera
local CameraLocation = Vector3.new(-22.5, 35.5, -58.5)
local CameraDirection = Vector3.new(-8, 4.5, -92)

cam.CameraType = Enum.CameraType.Scriptable

game["Run Service"].RenderStepped:connect(function()
    cam.CoordinateFrame = CFrame.new(CameraLocation,CameraDirection)
end)


--[[ Title Screen Script ]]


function onClicked()
    titlescreen:Destroy()
    cam.CameraType = Enum.CameraType.Fixed
end

titlebutton.MouseButton1Down:connect(onClicked)

1 answer

Log in to vote
1
Answered by
FiredDusk 1466 Moderation Voter
8 years ago

You have:

    cam.CameraType = Enum.CameraType.Fixed 

when it should be:

cam.CameraType = "Fixed"
0
Thanks! Pyrondon 2089 — 8y
0
np FiredDusk 1466 — 8y
0
Er, I changed it and the camera still stays fixed at that position? Pyrondon 2089 — 8y
0
I see you have "titlescreen" but you dont have a variable in the script you posted. I would mabey need t see the whole script to understand. Sorry, I am a bit new to scripting but could mabey help you out. FiredDusk 1466 — 8y
0
Titlescreen is all in the title screen script, my only problem right now is the camera. It changes to a fixed position but then refuses to follow the character again, even if the camera type is set to Fixed. I'm new as well, thanks for helping out. Pyrondon 2089 — 8y
Ad

Answer this question