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

How to make a npc move to your cursors location?

Ive been trying to make a game and it involves npcs moving to the press of my mouse now i already know the location of my mouse as i put this is starterpack local LocalPlayer = game.Players.LocalPlayer local mouse = LocalPlayer:GetMouse() mouse.KeyDown:Connect(function(key) print(key) end) mouse.Button1Down:Connect(function() print(tostring(mouse.Target.Name)..""..tostring(mouse.Hit.Position)) end) but i dont know how to use the location of the press to move the npc to that location can anyone help me?

2 comments

0

please format your code. you can do this by selecting your code, then pressing the "lua" icon

0

you can use the Humanoid:MoveTo function to move any character to a location. for more information go to the api reference

1 answer

This is on a localscript which means it will not show up for other people. Try using a regular script inside of the tool and firing a remoteevent to a localscript which would return a remote event to the script with the mouse.hit.p attatched. also, use Humanoid:MoveTo()

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