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

[SOLVED] i wanna make my part move up with the use of click detector. But it isnt working. Why?

Asked by 5 years ago
Edited 5 years ago
part = script.Parent

function Elevator()
    for i = 0, 100, 1 do
    game.Workspace.ElevatorPart.Position = Vector3.new(0, i, 0)
    wait(.1)

end

part.ClickDetector.MouseClick:Connect(Elevator())                      

I wanna make the "ElevatorPart" to move up as soon as i click on the click detector but it isnt working. why?

0
Exact same problem someone else was dealing with xD. I answered their question maybe it could help you https://scriptinghelpers.org/questions/76145/remote-event-one-of-2-args-become-nil-and-one-not GoldAngelInDisguise 297 — 5y

1 answer

Log in to vote
0
Answered by
Miniller 562 Moderation Voter
5 years ago

(You are not closing the 'for' loop, write 'end' to the end of the loop! But that won't solve the issue.) When you give it a new position, it's not giving +1 to the Y coordinate, it actually sets the position to 0, i, 0. You need to add i to the Y coordinate, like this:

for i = 0, 100, 1 do
    local ep = game.Workspace.ElevatorPart -- for the shorter script
    ep.Position = Vector3.new(ep.Position.X, ep.Position.Y + i, ep.Z)
end

Hope this helps.

Ad

Answer this question