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: Spawn script help? [Advanced]

Previous Thread :: Next Thread 
177117 is not online. 177117
Joined: 17 May 2010
Total Posts: 1366
28 Apr 2015 07:16 PM
So I got this script

bin=script.Parent
wait(.3)
zombie = bin:findFirstChild("Horse")

function onButton1Down(mouse)
local pos = mouse.hit.p
local model = zombie:clone()
model.Parent=game.Workspace
model:MakeJoints()
model:MoveTo(pos)
end

function onSelected(mouse)
mouse.Button1Down:connect(function () onButton1Down(mouse) end)
end

bin.Selected:connect(onSelected)

And it spawns a horse when the player clicks an area. Although, I want it so that players can only spawn a horse every 60 seconds. How do I achieve this?
Report Abuse
robotmega is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
28 Apr 2015 07:20 PM
local waiting = false
bin=script.Parent
wait(.3)
zombie = bin:findFirstChild("Horse")

function onButton1Down(mouse)
local pos = mouse.hit.p
local model = zombie:clone()
model.Parent=game.Workspace
model:MakeJoints()
model:MoveTo(pos)
end

function onSelected(mouse)
mouse.Button1Down:connect(function ()
if not waiting then
waiting = true
onButton1Down(mouse)
wait(60)
waiting = false
end
end)
end

bin.Selected:connect(onSelected)
Report Abuse
177117 is not online. 177117
Joined: 17 May 2010
Total Posts: 1366
28 Apr 2015 07:21 PM
Thank you so much! You made my day!
Report Abuse
FishIsBetterThanYou is not online. FishIsBetterThanYou
Joined: 10 Apr 2015
Total Posts: 115
28 Apr 2015 07:27 PM
no problem
Report Abuse
NotAshley is not online. NotAshley
Joined: 16 Jan 2014
Total Posts: 14257
28 Apr 2015 07:29 PM
This isn't really advanced.
Report Abuse
SummerEquinox is not online. SummerEquinox
Joined: 25 Jun 2013
Total Posts: 2088
28 Apr 2015 07:47 PM
I cannot tell a lie, fish "Fish" actually made me laugh there.


~R.I.P ROBLOX: http://www.roblox.com/Firefighter-Helmet-item?id=1081377 ~
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
28 Apr 2015 07:52 PM
Actually... This leave the thread open to waiting which is more cumbersome than...

local delay = 60
local last_time = tick()

function onClick()
local cur_time = tick()
if(cur_time % 60 > last_time+delay)then
--safe to execute
end
last_time = cur_time
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