Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would you decrease the size of a part using for i =1?

Asked by 10 years ago

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

0
Do you want it to shrink in all directions? And it is impossible for a brick's size to be equal to 0. RedCombee 585 — 10y
0
I know, I also thought of that just right now. Yeah, I'd like it to decrease in all directions. offbeatpizzalives123 105 — 10y

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

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.

Ad

Answer this question