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

MoveTo() seems to be acting quite strange? Character sometimes not moving?

Asked by 5 years ago

I am using MoveTo() to move a dummy character around but for some reason sometimes the character either 1. Doenst move at all 2. Moves then stops, moves then stops and so on. 3. Works perfect :)

Most of the time it does 1 or 2 but heres my code and a gif of whats happening. In the gif it does all 3 of the things listed above so you can see whats happening.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Player = game:GetService("Players").LocalPlayer

local GameSettings = require(ReplicatedStorage:WaitForChild("GameSettings"))

local Mouse = Player:GetMouse()
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local InGameCharacter = workspace:WaitForChild("CharacterModels"):WaitForChild(Player.Name .. "Character"):WaitForChild("Character")

function MouseButton2Down()
    print(1)
    InGameCharacter.Humanoid:MoveTo(Mouse.Hit.Position)
end

Mouse.Button2Down:Connect(MouseButton2Down)

https://gyazo.com/f8a1d5b24480afb2ce9613ff40edcbdd

You can also see the printing in the gif so you know when im clicking :)

Thank you and have a good day.

0
Use local for your functions. Everything else is local but the function isn't for some reason. It's important to be consistent. User#24403 69 — 5y
0
I dont see any "issues" hopefully someone finds a way to optimize this. DinozCreates 1070 — 5y

Answer this question