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

How do you fully stop more than one script with a button?

Asked by 7 years ago
Edited 7 years ago

Ok. For detail I'm creating a title screen for a game I'm currently working on. In the title screen, there is an orbit camera that keeps spinning. (Of which I put in a separate script) I want to know how to stop it using a button that I had already scripted. The button is NAMED PlayButton and when once you click the button it will make the title and the other buttons surrounding it disappear. Here is the script for PlayButton

script.Parent.Parent.Visible = true

script.Parent.MouseEnter:connect(function()
    script.Parent.BackgroundColor3 = BrickColor.Red().Color
end)

script.Parent.MouseLeave:connect(function()
    script.Parent.BackgroundColor3 = BrickColor.White().Color
end)

script.Parent.MouseButton1Click:connect(function()
    script.Parent.Text = "3"
    wait(1)
    script.Parent.Text = "2"
    wait(1)
    script.Parent.Text = "1"
    wait(1)
    script.Parent.Parent.Visible = false
    script.Parent.Parent.Parent.Title.Visible = false
end)

Now, here is the problem. I want to know how to stop the orbit camera just like how the PlayButton makes the title screen disappear. I'll tell you how the scripts are in order (layers) 1: Screen Gui - Ace Force 6 Menu 2: OrbitCamera; Frame(Has all of the button scripts); and Title. Note that all of these tabs I've mentioned are inside number 1.

Here is the Orbit Camera's local script that keeps spinning:

--Orbit and Recoil
repeat wait() until game.Players.LocalPlayer.Character

local camera = game.Workspace.CurrentCamera
local rs = game:GetService("RunService")

local step = 0

local rad = math.rad
local cos = math.cos
local sin = math.sin

local cf = CFrame.new
local ca = CFrame.Angles

rs:BindToRenderStep("Main",201,function()
    step = step + rad(0.5)

    camera.CFrame = cf(10,40,-8) * ca(0,step,0) * cf(0,0,5)
end)

If you want to check out the screen that's work in progress, go to https://www.roblox.com/games/712700161/Ace-Force-6 (Links won't work for some reason)

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

To make a script simply disable itself by button press you'd do,

script.Parent.Mouse1Click:connect(function()
wait()
script.Disabled = True

end)

With this your script would look like

script.Parent.Parent.Visible = true

script.Parent.MouseEnter:connect(function()
    script.Parent.BackgroundColor3 = BrickColor.Red().Color
end)

script.Parent.MouseLeave:connect(function()
    script.Parent.BackgroundColor3 = BrickColor.White().Color
end)

script.Parent.MouseButton1Click:connect(function()
    script.Parent.Text = "3"
    wait(1)
    script.Parent.Text = "2"
    wait(1)
    script.Parent.Text = "1"
    wait(1)
    script.Parent.Parent.Visible = false
    script.Parent.Parent.Parent.Title.Visible = false
   script.Disabled = True --You'd put it right over here, so after the script runs this last function the entire and I mean THE ENTIRE script shuts itself down!
end)


0
Thanks for the answer, but it only stops the button script not the orbit camera. I've tried this with the orbit it still won't work. laserhawk123 4 — 7y
0
Wait never mind it worked I just had to fiddle with the true and false lines. But now the only problem I have is the music. laserhawk123 4 — 7y
Ad

Answer this question