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

How come the part called "tune" keeps going up after I clicked it? (Different one)

Asked by 9 years ago

I am making a radio, where if I click the cylinder part, or tune is what it is called, it will turn to the Rotation number I put. But when I clicked it, it turned, but the position went up a little instead of staying there as 1.28. And when I clicked it again it didn't go back, but instead printed Off in the output. This is the script:

local tune = game.Workspace.Radio.Tune
sound = Instance.new("Sound", tune)
debounce = false

function onClicked()
    if not debounce then
    debounce = true
        tune.CFrame = CFrame.new(tune.CFrame.X, 1.28, tune.CFrame.Z)
        tune.Rotation = Vector3.new(89.999, -69.598, 89.999)
        sound.SoundId = "http://www.roblox.com/asset/id?=209864226"
        sound:Play()
    elseif debounce then
        tune.CFrame = CFrame.new(tune.CFrame.X, 1.28, tune.CFrame.Z)
        tune.Rotation = Vector3.new(89.999, -69.598, 89.999)
        print("Off")
    debounce = false
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

I want it where when I click it, it turns or rotate from what I put and when I click it again, it turns back to the rotation I put and then the music will be off. Hope I am giving a good explanation here.Thank you!

Answer this question