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

How to move a model after being clicked to a new clicked position?

Asked by 5 years ago

Hello,

I am trying to make a model move when you select it and then click on a position. The model will then move to that position. However nothing happens when I try to move the model. I am a beginner coder I am not very good.

The goal is to create a soldier in which I can click, then click on another position and then it moves to the new position.

local Mouse = game.Players.LocalPlayer:Getmouse()
Unit = LocalScript.parent
NewPosition = Mouse.Hit.p --Clicking on new position

Unit.ClickDetector.MouseClick:connect(function (NewPosition) --Person clicks on Model
    repeat
        wait(1) --waits until they click on new position
    until Mouse.Button1down == true
    Unit:Moveto (NewPosition) --Move model to new position
end)

Thank you for time, hello3396

0
There is a few things wrong with this at first glance. Is this script in the click detector? Bellyrium 310 — 5y
0
Any errors? OBenjOne 190 — 5y

Answer this question