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

How would I script 'audio upon victory'? [HELP NEEDED]

Asked by 8 years ago

If a team earns a certain amount of points on the leaderboard, an audio specific to their team will play. Here's what I have so far.

function RedChecker(points) -- This is fired when the number of points on the red team changes
    if points >= 100 then -- This then checks if the number of points is over or equal to a certain number of points, in this case 100
        game.Workspace.RedSound:Play() -- This will play the audio for when red team wins, you can change the "RedSound" to whatever you name your sound
    end
end

-- This is exactly the same as the function for red team, instead this is for blue team.
function BlueChecker(points)
    if points >= 100 then
        game.Workspace.BlueSound:Play()
    end
end

game.Workspace.RedPoints.Changed:connect(RedChecker)-- RedPoints would be the name of the IntValue for the red team
game.Workspace.BluePoints.Changed:connect(BlueChecker) -- BluePoints would be the name of the IntValue for the blue team
0
Does this not work..? It looks fine. If not, what's the issue with it? Pyrondon 2089 — 8y
0
I tested it, and for some odd reason, the audio doesn't play... BartyCrouchJunior 57 — 8y
0
Does the output say anything? Pyrondon 2089 — 8y
0
Nope. All appears to be fine. BartyCrouchJunior 57 — 8y
View all comments (3 more)
0
To debug, try putting print statements in various locations. ex, put a print statement before line 3. If it prints out when you expect it to, you know the problem is with playing the sound. chess123mate 5873 — 8y
0
barty crouch junior. AVADA KEDAVRA theCJarmy7 1293 — 8y
0
I tied debugging it, and all seems to be well. Maybe I should put the IntValues in the script? BartyCrouchJunior 57 — 8y

Answer this question