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

How do I break a function with a TextButton?

Asked by
Ulysies 50
8 years ago

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?

1 answer

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago

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.

0
Well I have done so, and still when I click on the GUI it dose nothing.. Ulysies 50 — 8y
0
connect only takes one argument 1waffle1 2908 — 8y
Ad

Answer this question