Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Wait before growing?

--When I walk on this part, it keeps growing from my legs touching it.
--How would I make a wait before it grows again?
x = script.Parent

x.Touched:connect(function()
	
	x.Size = x.Size + Vector3.new(1,1,1)
	x.CFrame = CFrame.new(-8,-1,-3)
end)

1 comment

0

You would need to use a Debounce; A Debounce is a thing-a-bob Variable that prevents a Function from firing multiple times on execution of the code (or chunk). WIKI Documentary on Debounce: http://wiki.roblox.com/index.php?title=Debounce

2 answers

✓ Accepted answer
x = script.Parent
settime= 1
mov = false

x.Touched:connect(function()
if mov == false then
mov=true
x.Size = x.Size + Vector3.new(1,1,1)
x.CFrame = CFrame.new(-8,-1,-3)
wait(settime)
mov=false
end
end)

1 comment

0

Watch this: https://gyazo.com/fb1d8b4a96a720c5d25bc145974934a6 I want when I touch it it grows 1,1,1+ then wait 1 second and if you touch it, it grows another 1,1,1+

As Alpha stated, you'd simply need to add in a debounce. To do this, you just need to add in a variable, which we can call "debounce" for simplicity. We'll set it up like this:

local x = script.Parent
local debounce = false

x.Touched:connect(function()
	if not debounce then --Checks if it's true
		debounce=true --Makes it so that it wont work until turned off.
		x.Size = x.Size + Vector3.new(1,1,1)
		x.CFrame = CFrame.new(-8,-1,-3)
		wait(1) --Waits before re-enabling it
		debounce=false --Sets it back to false so script can work
	end
end)

Ok, so now your script should work fine. If you have any further problems/questions, please leave a comment below. Hope I helped :P

####-Dyler3

This discussion is preserved as it was. New answers, comments, and votes are closed.