I have two TextButtons, when you hover over one, it changes the camera to a Control point and spins it around.
It works with one Gui button, but if you hover over another one, it glitches out and changes the camera to one or the other rapidly.
Any way how to fix this? I've heard of breaking the loop, but I don't know how to break it after the chunk of code.
Here's the script inside the button:
Torso = script.Parent.Parent.Parent.Parent.Parent.Character:WaitForChild("Torso")
MouseLeave = script.Parent.MouseLeave
script.Parent.MouseEnter:connect(function(mouse)
target = workspace.CP2.SpawnLocation
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = target
local angle = 0
while wait() do
camera.CoordinateFrame = CFrame.new(target.Position)
* CFrame.Angles(0, angle, 0)
* CFrame.new(0, 0, 15)
angle = angle + math.rad(0.6)
end
end)
script.Parent.MouseButton1Down:connect(function(bloop)
game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
game.Workspace.CurrentCamera.CameraType = "Custom"
Torso.CFrame = CFrame.new(target.Position)
script.Parent.Parent.Parent:Destroy()
end)

2 comments
Exactly what I would've done. Nice answer(:
THANKS!!!