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

My camera movement script isn't updating?

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)

1 comment

0

Try changing Left to Left.Value?

1 answer

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!

1 comment

0

I realise I could've just change the local Left but it's fine

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