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

Why is my camera not moving?

Asked by 3 years ago
Edited 3 years ago

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.

0
Any errors MattVSNNL 620 — 3y
0
No cheslin23t 4 — 3y

2 answers

Log in to vote
1
Answered by
pwx 1581 Moderation Voter
3 years ago

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
0
Okay, I'll try! cheslin23t 4 — 3y
0
Okay, will confirm it did change to scriptable, but nothing else is happening after. cheslin23t 4 — 3y
0
You could add Tween.Completed:Connect(function() print('tween completed') end) to see if the tween completes and tell me if it completes. pwx 1581 — 3y
0
Okay cheslin23t 4 — 3y
View all comments (5 more)
0
Not completing.. cheslin23t 4 — 3y
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 cheslin23t 4 — 3y
0
So the problem seems to be here: player.CharacterAdded:Wait() cheslin23t 4 — 3y
0
I removed player.CharacterAdded:Wait() and everything works! I am accepting this answer since he helped me the most! cheslin23t 4 — 3y
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. pwx 1581 — 3y
Ad
Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
3 years ago

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

0
You can manipulate the camera through the client, what do you mean? pwx 1581 — 3y
0
Sorry, not accepting it. Trying to set the clients camera.. Idc if exploiters mess with their own camera cheslin23t 4 — 3y

Answer this question