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

Translateby with a button?

Asked by
kbg123 0
10 years ago

I need a script for translateby and a button so that I can get a model to move left or right then stop. Then click the button again to move back to home position?

1 answer

Log in to vote
0
Answered by
ultrabug 306 Moderation Voter
10 years ago

You can use a for loop for this, for example;

local model=game.Workspace.Model
local part=game.Workspace.Part
part.ClickDetector.MouseClick:connect(function(pwc)
    for i=1,10 do
        model:TranslateBy(Vector3.new(0, 0.1, 0)
        wait(0.1)
    end
end)

this will make the model move up 1 stud in 1 second by 1 tenth of a stud per 1 tenth of a second.

0
I have the model and then a button with a click detector off to the side with this code in it. What would I do from there? kbg123 0 — 10y
0
I didn't give you the code to use in it, I gave you advice on how you could do it. But I wil change my answer to the script you would need. ultrabug 306 — 10y
0
Now you can just put that in the script and make sure the part w/ the clickdetector is named 'Part' and the model is named 'Model'. ultrabug 306 — 10y
Ad

Answer this question