Whats wrong with this script? it doesnt throw errors but it doesnt work either . it prints stuff though

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)
2 Likes
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?

1 Like

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’

2 Likes

Is this a local script? Or is it a server script.

1 Like

it is a local, you cannot get game.Players.LocalPlayer under server run context

2 Likes

The problem is with CFrame.Angles as @theseformasentence said

1 Like

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)
}```
2 Likes

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.

1 Like

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

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.