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

Why does my disc still keep spinning when music is turned off?

Asked by 9 years ago

So, the music plays and the Disc moves at the same time, but when it is turned of the disc still keeps moving.

local isOn = false
local Disc = script.Parent.Parent.Disc

function on()
    isOn = true
    script.Parent.Loop:Play()
    while true do
    wait(0.1)
    script.Parent.Parent.Disc.CFrame =
script.Parent.Parent.Disc.CFrame*CFrame.fromEulerAnglesXYZ(0,0.1,0)
    end 
end

function off()
    isOn = false
    script.Parent.Loop:Stop()
    wait(0.1)
    script.Parent.Parent.Disc.CFrame = script.Parent.Parent.Disc.CFrame*CFrame.fromEulerAnglesXYZ(0,0,0)
end

function onSelected(player,Choice)

    if Choice.Name == "on" then
        on()
    elseif Choice.Name == "off" then
        off()
    end
end

script.Parent.Dialog.DialogChoiceSelected:connect(onSelected)

1 answer

Log in to vote
0
Answered by 9 years ago

I think its that:

local isOn = false
local Disc = script.Parent.Parent.Disc

function on()
    isOn = true
    script.Parent.Loop:Play()
    repeat
    wait(0.1)
    script.Parent.Parent.Disc.CFrame =
    script.Parent.Parent.Disc.CFrame*CFrame.fromEulerAnglesXYZ(0,0.1,0)
    until isOn == false 
end

function off()
    isOn = false
    script.Parent.Loop:Stop()
    wait(0.1)
    script.Parent.Parent.Disc.CFrame = script.Parent.Parent.Disc.CFrame*CFrame.fromEulerAnglesXYZ(0,0,0)
end

function onSelected(player,Choice)

    if Choice.Name == "on" then
        on()
    elseif Choice.Name == "off" then
        off()
    end
end

script.Parent.Dialog.DialogChoiceSelected:connect(onSelected)

0
Thank You! It works! alan3401 28 — 9y
1
You're Welcome ! ;) XToonLinkX123 580 — 9y
Ad

Answer this question