Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is my camera not moving?

So, I have this local script for an intro in my game.


local player = game.Players.LocalPlayer

local camera = game.Workspace.CurrentCamera
print('testBefore')
camera.CameraType = Enum.CameraType.Scriptable
camera:GetPropertyChangedSignal("CameraType"):Wait()
camera.CameraType = Enum.CameraType.Scriptable
print('testAfter')
local tweenservice = game:GetService("TweenService")
local folder = game.Workspace.SpawnCam
camera.CameraType = Enum.CameraType.Scriptable
function tween(part1, part2)
	camera.CFrame = part1.CFrame
	local Tween = tweenservice:Create(camera, TweenInfo.new(10, Enum.EasingStyle.Linear), {
		CFrame = part2.CFrame
	})
	Tween:Play()
	Tween.Completed:Connect(function() print('tween completed') end)
	
end
cln = game.ReplicatedStorage.ScreenGui
cln = cln:Clone()
cln.Parent = player.PlayerGui
player.CharacterAdded:Wait()
player.PlayerGui:WaitForChild("Blackout")
while true do
tweenservice:Create(player.PlayerGui.Blackout.Frame, TweenInfo.new(1, Enum.EasingStyle.Linear), {
	BackgroundTransparency = 1
}):Play()
tween(folder["1"], folder["2"])
wait(9)
tweenservice:Create(player.PlayerGui.Blackout.Frame, TweenInfo.new(1, Enum.EasingStyle.Linear), {
	BackgroundTransparency = 0
}):Play()
wait(1)
tween(folder["3"], folder["4"])
tweenservice:Create(player.PlayerGui.Blackout.Frame, TweenInfo.new(1, Enum.EasingStyle.Linear), {
	BackgroundTransparency = 1
}):Play()
wait(9)
tweenservice:Create(player.PlayerGui.Blackout.Frame, TweenInfo.new(1, Enum.EasingStyle.Linear), {
	BackgroundTransparency = 0
}):Play()
wait(1)
tween(folder["5"], folder["6"])
tweenservice:Create(player.PlayerGui.Blackout.Frame, TweenInfo.new(1, Enum.EasingStyle.Linear), {
	BackgroundTransparency = 1
}):Play()
wait(9)
tweenservice:Create(player.PlayerGui.Blackout.Frame, TweenInfo.new(1, Enum.EasingStyle.Linear), {
	BackgroundTransparency = 0
}):Play()
wait(1)
end

My previous error had to do with the cameratype not changing, but now I have a different error: The camera is stuck in mid air.

2 comments

0

Any errors

0

No

2 answers

✓ Accepted answer

The CameraType automatically gets set after a Player is added, enough time for any LocalScript to set the CameraType. Your best bet is to add a check before hand, like so:

local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera:GetPropertyChangedSignal("CameraType"):Wait()
camera.CameraType = Enum.CameraType.Scriptable
-- rest of code here

9 comments

0

Okay, I'll try!

0

Okay, will confirm it did change to scriptable, but nothing else is happening after.

0

You could add Tween.Completed:Connect(function() print('tween completed') end) to see if the tween completes and tell me if it completes.

0

Okay

0

Not completing..

0

So I added a print before the wait statement you provided me, and after. They both print. I will edit my answer to match my current code

0

So the problem seems to be here: player.CharacterAdded:Wait()

0

I removed player.CharacterAdded:Wait() and everything works! I am accepting this answer since he helped me the most!

0

Ah, I see. For future reference use local Character = Player.Character or Player.CharacterAdded:Wait(), it both checks if the character is already there or wait for it load if it isn't.

You can't change server-sided stuff through a local script, Try using a remote event for that

2 comments

0

You can manipulate the camera through the client, what do you mean?

0

Sorry, not accepting it. Trying to set the clients camera.. Idc if exploiters mess with their own camera

This discussion is preserved as it was. New answers, comments, and votes are closed.