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

How do I make the arrow (Union) rotate and make the song work? (Edited)

Asked by 9 years ago

This script was fixed, but then I had to change it around since there was something that didn't do what I wanted it to do. Well, I made this different. Added three functions in here, but since there was too many code, I sticked with one. What I did was that is that the script will see what the decal id is and then put the song up with the id I provided them. But what happened was that the Arrow didn't rotate at all, and the song didn't even come on. I want the arrow to rotate to the rotation I gave them and then make the sound on if the decal id is there like I put. I hope you know what I mean. This is the script:

local arrow = game.Workspace.Arrow
local disc = game.Workspace.PlainDisc2.Decal
local sound = Instance.new("Sound", disc)
debounce = false
radioOn = false

function onClicked() -- Clicked
    if not debounce and not radioOn and disc.Texture == "rbxassetid://238387775" then --if debounce and radioOn is not true and the Image Id is 238387775 then
        debounce = true -- True
        radioOn = true -- Radio on
        arrow.Rotation = Vector3.new(arrow.Rotation.X, -45.124, arrow.Rotation.Z) -- Turn to turn the music on
        sound.SoundId = "rbxassetid://210232032" -- the Music in this Id
        sound:Play() --Play it
    elseif radioOn and sound.SoundId == "rbxassetid://210232032" and disc.Texture == "rbxassetid://238387775" then -- If the radioOn is true and the sound id and decal id is still the same then
        disc.Texture = "rbxassetid://" -- Disc texture id into nothing, so just plain
        radioOn = false --Radioon is false
        sound:Stop() --Stops the sound
        arrow.Rotation = Vector3.new(arrow.Rotation.X, 45.631, arrow.Rotation.Z) --This arrow should go back before the disc is plain and radioOn is false
        print("Off" and "PlainDisc") -- prints the Output off and that the disc is Plain
        debounce = false -- Debounce is false
    end
end

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

Answer this question