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?
(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.