generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Help fix this script pls

Previous Thread :: Next Thread 
SimplyClever is not online. SimplyClever
Joined: 19 Dec 2008
Total Posts: 39371
17 Jan 2015 05:00 AM
local Player = game.Players.LocalPlayer
local SoundPack = script:GetChildren()


Player.CharacterAdded:connect(function(Character)
local Humanoid = Character.Humanoid
Humanoid.Died:connect(function()
local RandomSound = SoundPack[math.random(1, 26)]
RandomSound.Parent = Player
RandomSound:Play()
end)
end)


it's inside a gui
local scrip obv
Report Abuse
drager980 is not online. drager980
Joined: 25 May 2009
Total Posts: 13385
17 Jan 2015 05:48 AM
im really not sure where your error is
whats the output?
unless you load all the sounds after the script is put in existance then idk lol
try v

game.Players.LocalPlayer.CharacterAdded:connect(function(Character)
local Humanoid = Character.Humanoid
Humanoid.Died:connect(function()
local SoundPack = script:GetChildren()
local RandomSound = SoundPack[math.random(1, #SoundPack)] -- im assuming 26 is all the sounds
RandomSound.Parent = Player
RandomSound:Play()
end)
end)



AND THE TIGER GOES ROAR
Report Abuse
drager980 is not online. drager980
Joined: 25 May 2009
Total Posts: 13385
17 Jan 2015 05:52 AM
probably should've gotten rid of soundpack entirely
local RandomSound = script:GetChildren()[math.random(1, #script:GetChildren())]
hehe


AND THE TIGER GOES ROAR
Report Abuse
SimplyClever is not online. SimplyClever
Joined: 19 Dec 2008
Total Posts: 39371
17 Jan 2015 06:24 AM
>[math.random(1, #script:GetChildren())]

wrong!!
Report Abuse
drager980 is not online. drager980
Joined: 25 May 2009
Total Posts: 13385
17 Jan 2015 06:26 AM
theres an extra ) at :GetChildren(),
remove it 4 fix :>



AND THE TIGER GOES ROAR
Report Abuse
parkiet3 is not online. parkiet3
Joined: 16 Jul 2011
Total Posts: 832
17 Jan 2015 06:27 AM
Add a print, im not sure if it runs the characteradded, cuz i think the character loads faster than guis
Report Abuse
SimplyClever is not online. SimplyClever
Joined: 19 Dec 2008
Total Posts: 39371
17 Jan 2015 06:29 AM
like this?

game.Players.LocalPlayer.CharacterAdded:connect(function(Character)
local Humanoid = Character.Humanoid
Humanoid.Died:connect(function()
local RandomSound = script:GetChildren()[math.random(1, 25)script:GetChildren()]
RandomSound.Parent = Player
RandomSound:Play()
end)
end)
Report Abuse
drager980 is not online. drager980
Joined: 25 May 2009
Total Posts: 13385
17 Jan 2015 06:32 AM
oh, i tried to fix something that wasnt inherently broken
but when you open out output does it have a specific error to it?
possible errors onthe randomsound line include
script:GetChildren() being nil
that's it :>



AND THE TIGER GOES ROAR
Report Abuse
SimplyClever is not online. SimplyClever
Joined: 19 Dec 2008
Total Posts: 39371
17 Jan 2015 06:34 AM
ocal RandomSound = script:GetChildren()[math.random(1, 25)script:GetChildren()]



>math.random(1, 25)script:

its bad
Report Abuse
drager980 is not online. drager980
Joined: 25 May 2009
Total Posts: 13385
17 Jan 2015 06:38 AM
it should still be this:
game.Players.LocalPlayer.CharacterAdded:connect(function(Character)
local Humanoid = Character.Humanoid
Humanoid.Died:connect(function()
local SoundPack = script:GetChildren()
local RandomSound = SoundPack[math.random(1, #SoundPack)] -- im assuming 26 is all the sounds
RandomSound.Parent = Player
RandomSound:Play()
end)
end)
if its bad then it'll say something in the output.



AND THE TIGER GOES ROAR
Report Abuse
drager980 is not online. drager980
Joined: 25 May 2009
Total Posts: 13385
17 Jan 2015 06:39 AM
game.Players.LocalPlayer.CharacterAdded:connect(function(Character)
local Humanoid = Character.Humanoid
Humanoid.Died:connect(function()
local RandomSound = script:GetChildren()[math.random(1, #script:GetChildren())] -- im assuming 26 is all the sounds
RandomSound.Parent = Player
RandomSound:Play()
end)
end)

misdid it AGAIN hnneueuugh




AND THE TIGER GOES ROAR
Report Abuse
SimplyClever is not online. SimplyClever
Joined: 19 Dec 2008
Total Posts: 39371
17 Jan 2015 06:40 AM
doesnt work qq
Report Abuse
drager980 is not online. drager980
Joined: 25 May 2009
Total Posts: 13385
17 Jan 2015 06:42 AM
game.Players.LocalPlayer.CharacterAdded:connect(function(Character)
local Humanoid = Character.Humanoid
Humanoid.Died:connect(function()
local RandomSound = script:GetChildren()[math.random(1, #script:GetChildren())] -- im assuming 26 is all the sounds
RandomSound.Parent = game.Players.LocalPlayer
RandomSound:Play()
end)
end)


should work



AND THE TIGER GOES ROAR
Report Abuse
drager980 is not online. drager980
Joined: 25 May 2009
Total Posts: 13385
17 Jan 2015 06:45 AM
game.Players.LocalPlayer.CharacterAdded:connect(function(Character)
local Humanoid = Character.Humanoid
Humanoid.Died:connect(function()
if game.Players.LocalPlayer:findFirstChild("Sound") then
game.Players.LocalPlayer:findFirstChild("Sound"):remove()
end
local RandomSound = script:GetChildren()[math.random(1, #script:GetChildren())]
RandomSound.Parent = game.Players.LocalPlayer
RandomSound:Play()
end)
end)

thisll make it so the sounds cant overlap
also are these meant to be death sounds or just changing music when you die, there is le difference.



AND THE TIGER GOES ROAR
Report Abuse
SimplyClever is not online. SimplyClever
Joined: 19 Dec 2008
Total Posts: 39371
17 Jan 2015 06:51 AM
death sounds


also only works in studio

df
Report Abuse
drager980 is not online. drager980
Joined: 25 May 2009
Total Posts: 13385
17 Jan 2015 06:54 AM
try this
game.Players.LocalPlayer.CharacterAdded:connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.Died:connect(function()
local RandomSound = script:GetChildren()[math.random(1, #script:GetChildren())]
RandomSound.Parent = Character
RandomSound:Play()
end)
end)



AND THE TIGER GOES ROAR
Report Abuse
SimplyClever is not online. SimplyClever
Joined: 19 Dec 2008
Total Posts: 39371
17 Jan 2015 06:56 AM
OGM

it finally works ily


also could u do that it stops on respawn
Report Abuse
drager980 is not online. drager980
Joined: 25 May 2009
Total Posts: 13385
17 Jan 2015 07:08 AM
game.Players.LocalPlayer.CharacterAdded:connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.Died:connect(function()
local RandomSound = script:GetChildren()[math.random(1, #script:GetChildren())]
RandomSound.Parent = Character
RandomSound.Played:connect(function() local RSV = RandomSound.Volume for i=1,50 do RandomSound.Volume = RSV - i * (RSV/50) wait(0.1) end end)
RandomSound:Play()
end)
end)




AND THE TIGER GOES ROAR
Report Abuse
SimplyClever is not online. SimplyClever
Joined: 19 Dec 2008
Total Posts: 39371
17 Jan 2015 07:36 AM
ur da best
Report Abuse
SimplyClever is not online. SimplyClever
Joined: 19 Dec 2008
Total Posts: 39371
17 Jan 2015 09:04 AM
everyone in the server hears the sound though :(
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image