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 4 years ago
Edited 4 years ago

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

01local player = game.Players.LocalPlayer
02 
03local camera = game.Workspace.CurrentCamera
04print('testBefore')
05camera.CameraType = Enum.CameraType.Scriptable
06camera:GetPropertyChangedSignal("CameraType"):Wait()
07camera.CameraType = Enum.CameraType.Scriptable
08print('testAfter')
09local tweenservice = game:GetService("TweenService")
10local folder = game.Workspace.SpawnCam
11camera.CameraType = Enum.CameraType.Scriptable
12function tween(part1, part2)
13    camera.CFrame = part1.CFrame
14    local Tween = tweenservice:Create(camera, TweenInfo.new(10, Enum.EasingStyle.Linear), {
15        CFrame = part2.CFrame
View all 54 lines...

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 — 4y
0
No cheslin23t 4 — 4y

2 answers

Log in to vote
1
Answered by
pwx 1581 Moderation Voter
4 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:

1local camera = workspace.CurrentCamera
2camera.CameraType = Enum.CameraType.Scriptable
3camera:GetPropertyChangedSignal("CameraType"):Wait()
4camera.CameraType = Enum.CameraType.Scriptable
5-- rest of code here
0
Okay, I'll try! cheslin23t 4 — 4y
0
Okay, will confirm it did change to scriptable, but nothing else is happening after. cheslin23t 4 — 4y
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 — 4y
0
Okay cheslin23t 4 — 4y
View all comments (5 more)
0
Not completing.. cheslin23t 4 — 4y
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 — 4y
0
So the problem seems to be here: player.CharacterAdded:Wait() cheslin23t 4 — 4y
0
I removed player.CharacterAdded:Wait() and everything works! I am accepting this answer since he helped me the most! cheslin23t 4 — 4y
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 — 4y
Ad
Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
4 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 — 4y
0
Sorry, not accepting it. Trying to set the clients camera.. Idc if exploiters mess with their own camera cheslin23t 4 — 4y

Answer this question