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

My camera movement script isn't updating?

Asked by
zomspi 541 Moderation Voter
4 years ago

I am making a 2D game and am trying to change the position of my camera when a value is changed although it doesn't seem to be working?

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local Left = script.Left


player.CharacterAdded:Wait()
player.Character:WaitForChild("HumanoidRootPart")

camera.CameraSubject = player.Character.HumanoidRootPart
camera.CameraType = Enum.CameraType.Attach
camera.FieldOfView = 70


    camera.CFrame = CFrame.new(Left,10,10)


Left.Changed:Connect(function()
player.CharacterAdded:Wait()
player.Character:WaitForChild("HumanoidRootPart")

camera.CameraSubject = player.Character.HumanoidRootPart
camera.CameraType = Enum.CameraType.Attach
camera.FieldOfView = 70


    camera.CFrame = CFrame.new(Left,10,10)
    end)

0
Try changing Left to Left.Value? Wiscript 622 — 4y

1 answer

Log in to vote
0
Answered by
zomspi 541 Moderation Voter
4 years ago
Edited 4 years ago

I get this error "Players.zomspi.PlayerScripts.CameraScript:17: attempt to index field 'Value' (a number value)"

My updated script

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local Left = script.Left


player.CharacterAdded:Wait()
player.Character:WaitForChild("HumanoidRootPart")

camera.CameraSubject = player.Character.HumanoidRootPart
camera.CameraType = Enum.CameraType.Attach
camera.FieldOfView = 70


    camera.CFrame = CFrame.new(Left,10,10)


Left.Value.Changed:Connect(function()
player.CharacterAdded:Wait()
player.Character:WaitForChild("HumanoidRootPart")

camera.CameraSubject = player.Character.HumanoidRootPart
camera.CameraType = Enum.CameraType.Attach
camera.FieldOfView = 70


    camera.CFrame = CFrame.new(Left.Value,10,10)
    end)

Thanks for the help though!

0
I realise I could've just change the local Left but it's fine zomspi 541 — 4y
Ad

Answer this question