Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

1 comment

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

1 answer

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.