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: Special Script

Previous Thread :: Next Thread 
Pikachu84639 is not online. Pikachu84639
Joined: 21 Nov 2011
Total Posts: 230
11 May 2015 06:24 PM
Hello fellow ROBLOXians,
I am trying to make a script where a sound is LOCALLY played for 20 seconds when the player enters the game. I have finished most of the script, but I'm trying to find out how I can have the sound play only on the entering player's device. This is my script so far:

sound=script.Sound

function enter()
sound:Play()
wait(20)
sound:Stop()
end

game.Players.PlayerAdded:connect(enter)

What should I add/change/remove to make the sound in my script play LOCALLY only?

Thank you for helping me.
Pikachu84639
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
11 May 2015 06:26 PM
local sound = script.Sound -- local variable, faster

game.Players.PlayerAdded:connect(function(p) -- more efficient that way
local soundClone = sound:Clone()
soundClone.Parent = p.PlayerGui
soundClone:Play()
soundClone:Stop()
soundClone:Destroy()
end) -- add a ) because we did it on 1 line
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
11 May 2015 06:33 PM
You parented it in the playergui, if the player dies, no more sound.

Parent it in the player instead.
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
11 May 2015 06:33 PM
that was @thenewchicken btw.

Report Abuse
Pikachu84639 is not online. Pikachu84639
Joined: 21 Nov 2011
Total Posts: 230
11 May 2015 06:52 PM
Thank you for that. I'm trying to make the sound play for only the first 20 seconds after the player joins the game. Can you please add that to the script?
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
11 May 2015 06:53 PM
I fixed his code and made it play for 20 seconds.

By fixed, it doesn't disappear when you die now.


local sound = script.Sound -- local variable, faster

game.Players.PlayerAdded:connect(function(p) -- more efficient that way
local soundClone = sound:Clone()
soundClone.Parent = p
soundClone:Play()
wait(20)
soundClone:Stop()
soundClone:Destroy()
end) -- add
Report Abuse
Pikachu84639 is not online. Pikachu84639
Joined: 21 Nov 2011
Total Posts: 230
11 May 2015 06:59 PM
I already tried adding wait(20), but it wouldn't do anything. The sound would just continue playing until its real end.
Report Abuse
Pikachu84639 is not online. Pikachu84639
Joined: 21 Nov 2011
Total Posts: 230
15 May 2015 08:06 PM
I already tried adding wait(20), but it wouldn't do anything. The sound would just continue playing until its real end.

So, does somebody have an answer?
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