Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

2 comments

0

Thank You! It works!

1

You're Welcome ! ;)

This discussion is preserved as it was. New answers, comments, and votes are closed.