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: How would you add a cooldown to this onTouched function?

Previous Thread :: Next Thread 
BookOfPowerz is not online. BookOfPowerz
Joined: 16 Dec 2013
Total Posts: 1082
13 Feb 2017 08:13 AM
function onTouched(hit)
if hit.Parent:findFirstChild('Humanoid') then
local player = game.Players:findFirstChild(hit.Parent.Name)
if player then
local N = script.Parent.Notice:clone()
N.Parent = player.PlayerGui
N.Frame.TextLabel.Text = "Strange Noises can be heard from within the Cave..."
game.Lighting.DialgaCry:Play()
wait(1)
game.Lighting.PalkiaCry:Play()
wait(3)
N.Parent = script.Parent
else
end
end
end
script.Parent.Touched:connect(onTouched)

After it's been touched, I want it so that it can be stepped on after 5 seconds but it won't disable the script.


#code print("Fire Dragon's Roar!!") --yes, i am natsu xd
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
13 Feb 2017 08:14 AM
###############################################
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
13 Feb 2017 08:15 AM
That was a roblox wiki link, what the heck.

The letter "a" is probably censored above too.

Check out Debounce on the ROBLOX wiki.

wiki.roblox.com/index.php?title=Debounce
Report Abuse
BookOfPowerz is not online. BookOfPowerz
Joined: 16 Dec 2013
Total Posts: 1082
13 Feb 2017 08:20 AM
I know how the wait part works but where would it go? I want the code to happen ## soon ## it's stepped on however, I want it to next work again after 5 seconds. #code ########### Dragon's Roar!!") --yes, i am natsu xd
Report Abuse
QuantumNexsus is not online. QuantumNexsus
Joined: 09 Nov 2014
Total Posts: 2451
13 Feb 2017 08:21 AM
Use TouchEnded


Report Abuse
BookOfPowerz is not online. BookOfPowerz
Joined: 16 Dec 2013
Total Posts: 1082
13 Feb 2017 08:24 AM
?
so i would change Touched to TouchEnded?


#code print("Fire Dragon's Roar!!") --yes, i am natsu xd
Report Abuse
QuantumNexsus is not online. QuantumNexsus
Joined: 09 Nov 2014
Total Posts: 2451
13 Feb 2017 08:26 AM
I havent really tried TouchedEnded but im sure you would need that to detect when the player has stopped touching it.


Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
13 Feb 2017 08:57 AM
local palkia = workspace.Sounds.Palkia
local dialga = workspace.Sounds.Dialga
--dont store anything in lighting
local part = script.Parent
local notice = part.Notice
local debounce = false

part.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not player or debounce then return end
debounce = true
local notice = notice:Clone()
notice.Parent = player.PlayerGui
notice:WaitForChild('Frame').TextLabel.Text = 'Strange Noises can be heard from within the Cave...'
dialga:Play()
wait(1)
palkia:Play()
wait(3)
notice:Destroy()
wait(1)
debounce = false
end)


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