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

Part stops at a certain point?

Asked by 5 years ago

I tried making a script where a part rises once clicked and it rises until a certain point, but when testing, it keeps rising on and on. Is there a way to make it stop once it is the same position on the y-axis?

local clickdetector = script.Parent
local part = workspace.Mark3

clickdetector.MouseClick:Connect(function()
repeat
wait(0)
for i = 1, 1 do
part.CFrame = part.CFrame * CFrame.new(0,0.1,0)
end
until part.Position.Y == workspace.Mark1.Position.Y
end)
0
use tweenservice INOOBE_YT 387 — 5y
0
oh ok meteorcrasher118 35 — 5y
0
or lerp the cframe theking48989987 2147 — 5y
0
Or you could just use a >= lol Vulkarin 581 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

There's no need for the for loop because of your repeat loop if you're just aiming to make part move up. I also recommend using addition to move the part upwards because multiplying any number by a decimal makes the product smaller.

Lastly, at the until part of your repeat loop, if the position is off by even a little bit over, it won't stop the loop so I recommend changing the == to a >= because >= means "is bigger than or equal to"

0
oh I didn't think of that! Thank you very much! meteorcrasher118 35 — 5y
Ad

Answer this question