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

Why does the camera glitch when trying to go back into player?

Asked by 7 years ago

So i'm making a drone. I scripted the movement, ect. The camera does attach to the part. When I try to go to the player, it just glitched out. I'm assuming it's coming from the loop. I've tried fixing this myself by removing the loop, which does work, but it only works once.

code:

plr = game.Players.LocalPlayer
cam = game.Workspace.CurrentCamera
chr = nil

plr.CharacterAdded:connect(function(character)
    chr=character
end)


script.Parent.Camera.MouseButton1Click:connect(function()
    if debounce == true then
        debounce = false
        while true do
            wait()
            cam.CoordinateFrame = CFrame.new(game.Workspace.Model.Part.Position)
            cam.CameraType = "Scriptable"
        end
    end
end)

script.Parent.BackToPlayer.MouseButton1Click:connect(function()
    while true do 
        wait()
        cam.CameraType = "Custom"
    end
    debounce = true
end)

If you have any questions, please put them in the comment

1 answer

Log in to vote
0
Answered by 7 years ago

You arent setting a CoordinateFrame or CameraSubject when you click BackToPlayer

script.Parent.BackToPlayer.Mousebutton1Click:connect(function()
    cam.CameraSubject = (whatever)
    cam.CameraType = "Custom"
    debounce = true

0
do I remove the while true do loop? DeveloperSolo 370 — 7y
0
Nvm I got it to work. Thanks DeveloperSolo 370 — 7y
Ad

Answer this question