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

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

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

✓ Accepted answer

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

2 comments

0

do I remove the while true do loop?

0

Nvm I got it to work. Thanks

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