I was trying to do this, when someone touches it, it would decrease into zero and killing someone. Here's what I got
function onTouched(hit) local Humanoid = hit.Parent:FindFirstChild("Humanoid") if Humanoid then for i = 1, 20 do script.Parent.Size = Size.new - 1 if script.Parent.Size == 0 then Humanoid.Health = -5 print("Execution was successful!") end end end end script.Parent.Touched:connect(onTouched)
I need a good answer :c
Size is a Vector3 value. On top of that, it would be better to set the the size to i, since you already have a changing variable. Also make sure you have a wait().
for i = 20,1,-1 do --Counts down from 20 script.Parent.Size = Vector3.new(i,i,i) wait(0.5)
You may also want to look into adding a debounce.