So I have a script in Workspace, with a local script inside it. Inside the normal script is
game.Players.PlayerAdded:connect(function(player) script.LocalScript:clone().Parent = player.CharacterAdded:wait() end)
Inside the localscript is
local target = workspace.GFrame --Location of target(the thing you want to spin around) local camera = workspace.CurrentCamera camera.CameraType = Enum.CameraType.Scriptable camera.CameraSubject = target local angle = 0 local begon = game.StarterGui.AtSpawn.AtSpawn.AtSpawn.Begin.TextButton --GUI Begin button local bob = 0 function bobsdeath() bob = bob + 1 end while wait() do --Spins camera camera.CoordinateFrame = CFrame.new(target.Position) --Start at the position of the part * CFrame.Angles(0, angle, 0) --Rotate by the angle * CFrame.new(0, 0, 5) --Move the camera backwards 5 units angle = angle + math.rad(1) if bob > 0 then break end end function begin()-- Returns cam to player game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid game.Workspace.CurrentCamera.CameraType = "Custom" end begon.MouseButton1Click:connect(bobsdeath,begin)
Whenever I click on the gui it does not end the function... Can someone help?
Anything you write after a loop will not happen until it ends. This means that nothing after line 19 ever happens. Move it all to before line 13.
connect
also does not take two arguments, it takes one. If you mean to connect to both of those functions, either combine the functions into one and connect to that, or create two connections for both functions.