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

CFraming or Camera Manipulation not working?

I see no errors in the output, idk why its not working since it worked the last time I made it. Script:

game.Players.PlayerAdded:connect(function(plr)
	local c = Instance.new("Part")
	c.Anchored = true
	c.Name = plr.Name.."'s Camera part"
	while not plr.Character do wait() end
	plr.Character:WaitForChild("Head")
	while true do
		wait()
		c.CFrame = plr.Character.Head.CFrame * CFrame.new(0,-5,0)
	end
	local target = c
	local camera = workspace.CurrentCamera
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CameraSubject = target
	local angle = 0
	camera.CoordinateFrame = CFrame.new(target.Position)
end)

(Script's in ServerScriptService)

This is a normal script

When I test it, it doesn't even create a part..

1 answer

✓ Accepted answer

Your first error here is to forgot to set the parent of your variable named as "c" and your second error is your script is a sever script but for got the camera you need to be in a local script because the camera of the player is local and your third is not really an error but you can't run a code after you do "while true do" your line 11 will never run so for fix that you'll need to use coroutine if you want to more know about coroutine go here. now your code suppose to look like that:

local plr = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local c = Instance.new("Part")
local target = c

c.Anchored = true
c.Name = plr.Name.."'s Camera part"
while not plr.Character do wait() end
plr.Character:WaitForChild("Head")

local angle = 0
c.Parent = camera
camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = target
camera.CoordinateFrame = target.CFrame 

coroutine.resume(coroutine.create(function()
    while true do
        wait()
		camera.CameraSubject = target
        c.CFrame = plr.Character.Head.CFrame * CFrame.new(0,-5,0)
    end
end))

Don't forgot to put it in a LocalScript in the backpack !

7 comments

0

You need to change the plr variables to player or vice versa.

0

I know I edited but thanks for informed

0

The camera glitches to somewhere else than where its supposed to be.

0

Now try, I edited

0

Still doesn't work as a LocalScript in the playey's backpack.

0

ommg i finally fixed it thx!

0

You're welcome !

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