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
wait(.5)

while wait() do
for i,v in pairs(script.Parent.Parent:GetChildren()) do
    if v.Name ~= "FieldTouch" then
        if v.Health.Value < 2 then
            local median = (v.Size.Y - v.Health.Value)
            v.Size = v.Size - Vector3.new(0,median,0)
            v.Position = v.Position - Vector3.new(0,median,0)
        end

    end
end
end

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:

wait(.5)

while wait() do
    for i,v in pairs(script.Parent.Parent:GetChildren()) do
        if v.Name ~= "FieldTouch" then
            if v.Health.Value < 2 then
                local median = (v.Size.Y - v.Health.Value)
                v.Size = v.Size - Vector3.new(0,median,0)
            if v.Position.Y - median >=1 then
                    v.Position = v.Position - Vector3.new(0,median,0)
            else 
            v.Position = v.Position - Vector3.new(0,median / 2,0)
           end
            end
        end
    end
end

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