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

Help me out here?

Asked by
steev 0
10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

The model goes up in the air but it doesn't go back to its original position when i click the button.

local model = game.Workspace["MODELNAME"]; -- The model you want to move up
local increment = 0.5 --The amount you want it to go up by each time
local max = 10 --The studs you want to go up by
local Button = script.Parent.ClickDetector --Change this to the ClickDetector.
local closed = true;
function onClick()
    if closed then
        move = increment 
    else 
        move = -increment 
    end 
    closed = not closed
    for i=1, max/increment do
        model:TranslateBy(Vector3.new(0,move,0));
    wait(1/60)
    end
end

Button.MouseClick:connect(onClick());

1 answer

Log in to vote
-1
Answered by
AxeOfMen 434 Moderation Voter
10 years ago

You are invoking the onClick function when you are attempting to connect it to the MouseClick event.

Button.MouseClick:connect(onClick());

should be

Button.MouseClick:connect(onClick);

Ad

Answer this question