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

How can you keep the brick from going into the baseplate in vector3?

Asked by 6 years ago
01wait(.5)
02 
03while wait() do
04for i,v in pairs(script.Parent.Parent:GetChildren()) do
05    if v.Name ~= "FieldTouch" then
06        if v.Health.Value < 2 then
07            local median = (v.Size.Y - v.Health.Value)
08            v.Size = v.Size - Vector3.new(0,median,0)
09            v.Position = v.Position - Vector3.new(0,median,0)
10        end
11 
12    end
13end
14end

Its supposed to go downwards but it ends up just going through the baseplate. I just need it to stay above the baseplate but also shrink.

1 answer

Log in to vote
2
Answered by 6 years ago
Edited 6 years ago

If you want to make the part stay in place but increase size, then it's important to know that: when you add X amount of size, the relativity for positioning it is 1/2 X. But since you want the part to go down,

read the following:

If you want the part to go down, but you don't want it to go through the baseplate, use an if statement, like so:

01wait(.5)
02 
03while wait() do
04    for i,v in pairs(script.Parent.Parent:GetChildren()) do
05        if v.Name ~= "FieldTouch" then
06            if v.Health.Value < 2 then
07                local median = (v.Size.Y - v.Health.Value)
08                v.Size = v.Size - Vector3.new(0,median,0)
09            if v.Position.Y - median >=1 then
10                    v.Position = v.Position - Vector3.new(0,median,0)
11            else
12            v.Position = v.Position - Vector3.new(0,median / 2,0)
13           end
14            end
15        end
16    end
17end

What that does, is if the part is shrinking and going down and about to go through the baseplate, then it will make it only shrink and not go down.

Let me know if this worked by accepting my answer! If it still didn't work, or you have trouble understanding something, leave a comment and I will reply.

1
Thanks for the answer but there is still a problem, depending on how much damage the tool did, it will either go to the middle or go down but still position through the baseplate after the health is 0. Odawg566 9 — 6y
Ad

Answer this question