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

CFraming or Camera Manipulation not working?

Asked by 8 years ago

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

Log in to vote
1
Answered by 8 years ago

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 !

0
You need to change the plr variables to player or vice versa. Spongocardo 1991 — 8y
0
I know I edited but thanks for informed XToonLinkX123 580 — 8y
0
The camera glitches to somewhere else than where its supposed to be. Operation_Meme 890 — 8y
0
Now try, I edited XToonLinkX123 580 — 8y
View all comments (3 more)
0
Still doesn't work as a LocalScript in the playey's backpack. Operation_Meme 890 — 8y
0
ommg i finally fixed it thx! Operation_Meme 890 — 8y
0
You're welcome ! XToonLinkX123 580 — 8y
Ad

Answer this question