Cam script i stole not working

this camera is used for build mode

i got this script from somewhere on the forum but it does not work for me, am i doing something wrong? i have a script that makes the camera scriptable and sets its cframe position

the script that doesn’t work: – i’m not good at cframe stuff

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local function onKeyPressed(Key)
	local cam = game.Workspace.CurrentCamera
	if Key == 'A' then
		cam.CFrame = cam.CFrame * cam.CFrame.RightVector * -1
	elseif Key == 'D' then
		cam.CFrame = cam.CFrame * cam.CFrame.RightVector * 1
	elseif Key == 'W' then
		cam.CFrame = cam.CFrame * cam.CFrame.LookVector * 1
	elseif Key == 'S' then
		cam.CFrame = cam.CFrame * cam.CFrame.LookVector * -1
	end
end

mouse.KeyDown:connect(function(key)
	if script.Parent.Visible == true then
		onKeyPressed(key)
	end
end)

thanks so much for any help :heart_on_fire:

You should check if the player character exists and wait for it

1 Like

that did not do anything but thanks for trying