So I'm working on making a cinematic and I'm just fooling around with the code and stuff, however I hit an early bump and I can't seem to figure out what's going on. If you scroll out, then hit F, it works like a charm. However, if you scroll all the way in, for some reason, the camera spazzes like crazy. My goal is to get it working in first person. Here's the code:
repeat wait() until game.Players.LocalPlayer.Character
--// Services
local rendered = game:GetService('RunService').RenderStepped
local uis = game:GetService('UserInputService')
--// Variables
local player = game.Players.LocalPlayer
local char = player.Character
local cam = workspace.CurrentCamera
local neck = char:WaitForChild('Torso'):WaitForChild('Neck')
local Active = false
local playerScripts = player:WaitForChild('PlayerScripts')
local camControl = playerScripts:WaitForChild('CameraScript')
local controlScript = playerScripts:WaitForChild('ControlScript')
--// Functions
function Start()
char:WaitForChild('Humanoid').JumpPower = 0
char:WaitForChild('Humanoid').WalkSpeed = 0
Active = true
end
function End()
char:WaitForChild('Humanoid').JumpPower = 50
char:WaitForChild('Humanoid').WalkSpeed = 16
Active = false
end
--// Connections
uis.InputBegan:connect(function(input,chat)
if not chat then
if input.KeyCode == Enum.KeyCode.F then
Start()
end
end
end)
--// Renders
rendered:connect(function()
if Active then
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = char:WaitForChild('Head').CFrame + cam.CFrame.lookVector
--neck.C1 = neck.C1:lerp(CFrame.Angles(0,85,0), 0.2)
else
cam.CameraType = Enum.CameraType.Custom
end
end)
What is going on..?

1 comment
use CharacterAdded:Wait()