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

How would I script an 'audio upon victory'? [closed]

Asked by 8 years ago

For example, if the Red team earns a certain amount of points on the leaderboard, an audio will play. This would be different for the color of the team, so if blue team wins, a different audio plays.

Closed as Not Constructive by Shawnyg and EzraNehemiah_TF2

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 8 years ago

This isn't a request site, but to help you get started I'll give you this:

You could start by having two IntValues - one for each team - to act as a counter for each team's number of points. You can come up with how/when you want points added to these however you want.

Then you could make another script with two functions that get called whenever either one of the IntValues' value changes. You could do this by doing for example: RedPoints.Changed:connect(function)and BluePoints.Changed:connect(function). These could lead to individual functions that will check the number of points for each team.

Inside these functions you could have if statements to check if one of the teams has exceeded a certain number of points needed to win.

Here's a little script to help you get started:

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
"Please upvote if this helped you", The upvote button isn't to be abused. It's only if someone makes a good quality question. This is a good quality question but asking for upvotes when not really needed is not good. EzraNehemiah_TF2 3552 — 8y
Ad