I made this is (which took me a week to finish it from watching videos) and what I want to do is add sounds to each of them. Like when someone is a murder, sheriff, or innocent and there is a sound to it when it says it. Also when one of them wins, there is a victory or losing sound as well. Just like any other murder games or mainly like TMM. Please tell me where to put it. This is the script I made:
--Made by benthekarateboy local gui = script.Parent local player = game.Players.LocalPlayer local replicatedstorage = game:GetService("ReplicatedStorage") local statustag = replicatedstorage:WaitForChild("StatusTag") local timertag = replicatedstorage:WaitForChild("TimerTag") local statustitle = gui:WaitForChild("StatusTitle") local event = replicatedstorage:WaitForChild("RemoteEvent") local pointsvalue = player:WaitForChild("Points") local multipliervalue = player:WaitForChild("Multiplier") local emeraldswordvalue = player:WaitForChild("EmeraldSword") local resultprompt = gui:WaitForChild("ResultPrompt") local resultname = resultprompt:WaitForChild("ResultName") local resultdesc = resultprompt:WaitForChild("ResultDescription") local classprompt = gui:WaitForChild("ClassPrompt") local classname = classprompt:WaitForChild("ClassName") local classdesc = classprompt:WaitForChild("ClassDescription") local pointslabel = gui:WaitForChild("PointsLabel") local pointsbutton = pointslabel:WaitForChild("Button") local pointstext = pointslabel:WaitForChild("DisplayText") local killerchance = gui:WaitForChild("KillerChance") local killerchancebutton = killerchance:WaitForChild("Button") local killerchancetext = killerchance:WaitForChild("DisplayText") local emeraldswordbutton = gui:WaitForChild("EmeraldSwordButton") local killerchancewindow = gui:WaitForChild("KillerChanceWindow") local killerchancebuy = killerchancewindow:WaitForChild("BuyButton") local killerchanceclose = killerchancewindow:WaitForChild("XButton") local emeraldswordwindow = gui:WaitForChild("EmeraldSwordWindow") local emeraldswordbuy = emeraldswordwindow:WaitForChild("BuyButton") local emeraldswordclose = emeraldswordwindow:WaitForChild("XButton") function secondstotimer(seconds) local minutes = math.floor(seconds / 60) local remainingseconds = seconds % 60 if remainingseconds <= 0 then remainingseconds = "00" elseif remainingseconds <= 9 then remainingseconds = "0" .. tostring(remainingseconds) else remainingseconds = tostring(remainingseconds) end return tostring(minutes) .. ":" .. remainingseconds end function updatestatus() if timertag.Value < 0 then statustitle.Text = statustag.Value else statustitle.Text = statustag.Value .. " (" .. secondstotimer(timertag.Value) .. ")" end if statustag.Value == "Intermission" then statustitle.TextColor3 = Color3.new(203/255, 1, 1) elseif statustag.Value == "Match" then statustitle.TextColor3 = Color3.new(1, 1, 203/255) elseif statustag.Value == "Loading Map" or statustag.Value == "Waiting for Players" then statustitle.TextColor3 = Color3.new(203/255, 1, 203/255) end end timertag.Changed:connect(updatestatus) statustag.Changed:connect(updatestatus) updatestatus() event.OnClientEvent:connect(function(...) local tuple = {...} if tuple[1] == "Result" then if tuple[2] == "KillerWin" then resultname.Text = "Mad Killer Wins!" resultname.TextColor3 = Color3.new(1, 74/255, 77/255) resultdesc.Text = "All players were killed." else resultname.Text = "Players Win!" resultname.TextColor3 = Color3.new(111/255, 149/255, 1) resultdesc.Text = "The Mad Killer was captured." end resultprompt.Visible = true resultprompt.Position = UDim2.new(0, -400, .5, -92) resultprompt:TweenPosition(UDim2.new(.5, -170, .5, -92), "Out", "Quad", 1) wait(7) resultprompt:TweenPosition(UDim2.new(1, 60, .5, -92), "Out", "Quad", 1) elseif tuple[1] == "Class" then if tuple[2] == "Killer" then classname.Text = "You are the Mad Killer" classname.TextColor3 = Color3.new(1, 74/255, 77/255) classdesc.Text = "Your goal is to kill everyone!" elseif tuple[2] == "Sheriff" then classname.Text = "You are the Sheriff" classname.TextColor3 = Color3.new(111/255, 149/255, 1) classdesc.Text = "Your goal is to find the Mad Killer and put them away for good!" else classname.Text = "You are an Eyewitness" classname.TextColor3 = Color3.new(117/255, 1, 156/255) classdesc.Text = "Help the Sheriff find the Mad Killer." end classprompt.Visible = true classprompt.Position = UDim2.new(0, -400, .5, -92) classprompt:TweenPosition(UDim2.new(.5, -170, .5, -92), "Out", "Quad", 1) wait(7) classprompt:TweenPosition(UDim2.new(1, 60, .5, -92), "Out", "Quad", 1) end end) function updatepoints() pointstext.Text = pointsvalue.Value end pointsvalue.Changed:connect(updatepoints) updatepoints() function updatemultiplier() killerchancetext.Text = "x " .. multipliervalue.Value end multipliervalue.Changed:connect(updatemultiplier) updatemultiplier() function updateemeraldsword() if emeraldswordvalue.Value == 0 then emeraldswordbuy.Visible = true else emeraldswordbuy.Visible = false end end emeraldswordvalue.Changed:connect(updateemeraldsword) updateemeraldsword() function closewindows() emeraldswordwindow.Visible = false killerchancewindow.Visible = false end killerchanceclose.MouseButton1Down:connect(closewindows) emeraldswordclose.MouseButton1Down:connect(closewindows) killerchancebuy.MouseButton1Down:connect(function() event:FireServer("Buy", "KillerChance") closewindows() end) emeraldswordbuy.MouseButton1Down:connect(function() event:FireServer("Buy", "EmeraldSword") closewindows() end) pointsbutton.MouseButton1Down:connect(function() closewindows() event:FireServer("Buy", "100Points") end) killerchancebutton.MouseButton1Down:connect(function() if killerchancewindow.Visible then closewindows() else closewindows() killerchancewindow.Visible = true end end) emeraldswordbutton.MouseButton1Down:connect(function() if emeraldswordwindow.Visible then closewindows() else closewindows() emeraldswordwindow.Visible = true end end)
Please tell me where to put it.
Please don't post 100, almost 200 lines of code asking where to put something.. Most people will just ignore it, and it's hard for us to help you that way.
To make sounds happen whenever the player is chosen then what you have to do is first have the sounds laid out, like so:
local murderSound = game.ServerStorage:FindFirstChild("MuderSound") local sherifSound = game.ServerStorage:FindFirstChild("SherifSound") local innocentSoun = game.ServerStorage:FindFirstChild("InnocentSound")
And next, whenever you're choosing the murderer, or Sherrif, then clone the sounds into their PlayerGui
local players = game.Players:GetPlayers() local murderer local sherrif function chooseMurderer() local murderer = players[math.random(1,#players)] --Randomized return murderer; end function chooseSherrif() local sherrif = players[math.random(1,#players)] if sherrif == murderer then --Make sure the Sherrif isn't the murderer chooseSherrif() --Re pick until the sherrif isn't the murderer else return sherrif; end end --Define Murderer and Sherrif-- murderer = chooseMurderer() sherrif = chooseSherrif() --Clone sounds-- local mSound = murderSound:Clone() mSound.Parent = murderer.PlayerGui mSound.Name = "Sound" local sSound = sherifSound:Clone() sSound.Parent = sherrif.PlayerGui sSound.Name = "Sound"
Then you'll have to clone the Innocent sound into everyone else's playergui
for i,v in pairs(players) do --We've already defined it if v ~= murderer and v ~= sherrif then --make sure it's not the murderer or sherrif local iSound = innocentSound:Clone() iSound.Parent = v.PlayerGui iSound.Name = "Sound" end end
And then, after you teleport all the players to the arena, play the sounds. They're all named 'Sound' so you can index every sound the same.
for i,v in pairs(players) do local sound = v.PlayerGui:FindFirstChild("Sound") --In case someone's new if sound then sound:Play() end end
So your final result should look something like this, Note: This is a guideline not an exact script, you'll have to manipulate it to your uses.
local murderSound = game.ServerStorage:FindFirstChild("MuderSound") local sherifSound = game.ServerStorage:FindFirstChild("SherifSound") local innocentSoun = game.ServerStorage:FindFirstChild("InnocentSound") local players = game.Players:GetPlayers() local murderer local sherrif function chooseMurderer() local murderer = players[math.random(1,#players)] --Randomized return murderer; end function chooseSherrif() local sherrif = players[math.random(1,#players)] if sherrif == murderer then --Make sure the Sherrif isn't the murderer chooseSherrif() --Re pick until the sherrif isn't the murderer else return sherrif() end end murderer = chooseMurderer() sherrif = chooseSherrif() local mSound = murderSound:Clone() mSound.Parent = murderer.PlayerGui mSound.Name = "Sound" local sSound = sherifSound:Clone() sSound.Parent = sherrif.PlayerGui sSound.Name = "Sound" for i,v in pairs(players) do --We've already defined it if v ~= murderer and v ~= sherrif then --make sure it's not the murderer or sherrif local iSound = innocentSound:Clone() iSound.Parent = v.PlayerGui iSound.Name = "Sound" end end for i,v in pairs(players) do local sound = v.PlayerGui:FindFirstChild("Sound") --In case someone's new if sound then sound:Play() end end --Then you'll probably want to delete the sounds from everyone's PlayerGui
Locked by EzraNehemiah_TF2, Redbullusa, adark, and BlueTaslem
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?