local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
local plus = script.Parent.Plus
local minus = script.Parent.Minus
local cameranumber = 1
local cameras = {
CFrame.new(-1.056, 8.86, 16.517) * CFrame.Angles(-14.7, 20.233, 0),
CFrame.new(-11.612, 5.66, -81.757) * CFrame.Angles(-12.047, -175.303, 0),
CFrame.new(34.867, 8.984, -27.612) * CFrame.Angles(0,90,0),
CFrame.new(-8, 80.772, -31.125) * CFrame.Angles(-90, -0, 0)
}
camera.CFrame = CFrame.new(-1.056, 8.86, 16.517) * CFrame.Angles(-14.7, 20.233, 0)
plus.Activated:Connect(function()
if cameranumber < 4 then
cameranumber += 1
else
cameranumber = 1
end
camera.CFrame = cameras[cameranumber]
end)
minus.Activated:Connect(function()
if cameranumber > 1 then
cameranumber -= 1
else
cameranumber = 4
end
camera.CFrame = cameras[cameranumber]
end)
local cameras = {
(CFrame.new(-1.056, 8.86, 16.517) * CFrame.Angles(-14.7, 20.233, 0)),
(CFrame.new(-11.612, 5.66, -81.757) * CFrame.Angles(-12.047, -175.303, 0)),
(CFrame.new(34.867, 8.984, -27.612) * CFrame.Angles(0,90,0)),
(CFrame.new(-8, 80.772, -31.125) * CFrame.Angles(-90, -0, 0))
}
also try to print cameras[cameranumber]
do this work as expected?
What is wrong with it?
Also all of your CFrame.Angles are formatted incorrectly; CFrame.Angles takes in radians, not degrees
To change this put your degrees into this function: math.rad(45) — 360 will turn into 2’pi’
Is this a local script? Or is it a server script.
it is a local, you cannot get game.Players.LocalPlayer under server run context
like this?
local cameras = {
CFrame.new(-1.056, 8.86, 16.517) * CFrame.Angles(math.rad(-14.7), math.rad(20.233), 0),
CFrame.new(-11.612, 5.66, -81.757) * CFrame.Angles(math.rad(-12.047), math.rad(-175.303), 0),
CFrame.new(34.867, 8.984, -27.612) * CFrame.Angles(0, math.rad(90), 0),
CFrame.new(-8, 80.772, -31.125) * CFrame.Angles(math.rad(-90), 0, 0)
}```
Try printing inside these events to see if they get fired. It could be that the buttons don’t have Active
enabled or they are inside a SurfaceGui
without AlwaysOnTop
enabled.
Also, your LocalScript must be under PlayerScripts
or CharacterScripts
or PlayerGui
to work. (StarterPlayerScripts
, StarterCharacterScripts
and StarterGui
). Note that don’t have to be directly under, just make sure their ancestor are these 3.
i found the problem. it was because the script was setting the camera type before the camera even loaded so it kept going back to custom
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.