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 (2)? {Wasn't Answered}

Asked by 8 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)


1 answer

Log in to vote
1
Answered by
Validark 1580 Snack Break Moderation Voter
8 years ago

There are a lot of things that didn't quite make sense in your script.

Please actually look at the differences. I mostly just moved lines around. Look at why this way makes more sense.

local arrow = game.Workspace.Arrow
local disc = game.Workspace.PlainDisc2
local sound = Instance.new("Sound", disc)
sound.SoundId == "rbxassetid://210232032"
debounce = false
radioOn = false

function onClicked() -- Clicked
    if not debounce then
        debounce = true

        if not radioOn then
            radioOn = true -- Turn Radio on
            disc.Texture == "rbxassetid://238387775"
            arrow.Rotation = Vector3.new(arrow.Rotation.X, -45.124, arrow.Rotation.Z) -- Turn to turn the music on
            sound:Play() --Play it
        elseif radioOn then
            disc.Texture = "" -- Set Disc texture to nothing
            radioOn = false -- Turn Radio off
            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\n".."PlainDisc") -- prints
        end

        debounce = false
    end
end

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



0
Thanks alot Validark, when I looked at it, I was like, wow how come I didn't even see that, how, HOW come I didn't see that. Thanks for fixing it. Pretty much I had to fix a little bit from this script. Anyway, THANK YOU SOO MUCH VALIDARK RobotChitti 167 — 8y
0
Yup. Happy scripting. Validark 1580 — 8y
Ad

Answer this question