Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script for playing sound if Player wins a round?

I am new to scripting and I was wondering if anyone knows a script that'll play a sound id upon the player winning a round? Thanks in advance

2 answers

Hello, Hubba_Popz!

You use this script to make a sound play =D

function PlaySound(SoundId)
	local sound = Instance.new("Sound")
	sound.SoundId = "http://www.roblox.com/asset/?id=" .. SoundId
	sound.Parent = game.Workspace
	wait(sound.TimeLenght)
	sound:Destroy()
end

PlaySound(000000) -- Change the "000000" to the sound id

Good Luck with your games!

I would create a local variable called "wins" and set it's value to false. Then you can script something for winning and change the wins variable to true. The next step would be playing the sound. You will need a sound in Workspace or where-ever you have it ready for use. I would use a local script if you want to make a random sound script (mainly because you might want other players to hear different sounds). What I mean by that is it picks a random sound from the location of where the sounds are and plays that. Here is an example of what would work. NOTE: this is a very basic version of what you can do.

local wins = false

if wins == true then
	game.Workspace.Sound.Playing = true
	wait(10)
	game.Workspace.Sound.Playing = false
else
	wins = false
	print("You did not win")
end

Just an example. You will have to do the rest. Hope this helps

Here's a link to help you with randomly picking stuff:

http://wiki.roblox.com/index.php/Random_numbers

This discussion is preserved as it was. New answers, comments, and votes are closed.