So I playtested my games 2 times, it worked. Maybe the problem isn’t solved yet but we know how to fix it. @JackscarIitt @B2ontwitch
If it still doesn’t work, I can do a Touched:Wait()
and cancel the MoveTo
and do the next function
Good idea, but the problem is it can fire if something
else touches. I would do
local TouchedWait = part.Touched:Connect(function(object)
if object.Parent == npc then
TouchedWait:Disconnect()
else
part.Touched:Wait()
end
end)
part.Touched:Wait()
It happened again.
I’ll try something like this:
hum:MoveTo(AtDeskA.Position)
AtDeskA.Touched:Connect(function(object)
if object:FindFirstFhild("Humanoid") then --basically checking for a Humanoid
--Rest of the code
end
end)
Wait something weird happened. MY PROGRESS WASN’T SAVED
Nevermind, SOME of it was saved for some weird reason.
Use magnitude condition checking instead of hum.MoveToFinished:Wait()
. Maybe that’ll solve the problem.
By that I mean
repeat wait() until (PrimaryPart.Position - Desk.Position).Magnitude < 2
.
Adjust the 2 a bit to your own liking.
I’ve never used magnitude, could you briefly explain it or send an article?
(Part1.Position - Part2.Position).Magnitude
==> Calculates the distance between 2 parts in studs.
magnitude is the distance between 2 objects
for example my character’s head and a random part
to find the difference of studs between those 2 objects what we can do is :
game.Players.PlayerAdded:Connect(function(player)
local part = workspace.Part
local distance = (Part.Position - player.Character.Head.Position).magnitude
print(distance)
end)
The result will be coming in studs
I’ll try this and other solutions. I’ll comeback with answers and let’s hope it works. @Zohair_028 @Lin27 @JackscarIitt @B2ontwitch
So @JackscarIitt @Zohair_028 @B2ontwitch @Lin27, I did a touch event. So if there’s any problems I’ll comeback.
Script:
local sun = script.Parent
local humanoid = sun.Humanoid
humanoid:MoveTo(workspace.AtDeskA.Position)
game.Workspace.AtDeskA.Touched:Connect(function(hit)
if (hit.Parent:FindFirstChild("Humanoid") ~= nil) then
print(workspace.AtDeskA)
humanoid:MoveTo(workspace.AtDesk.Position)
humanoid.MoveToFinished:Wait()
humanoid:MoveTo(workspace.AtDesk2.Position)
humanoid.MoveToFinished:Wait()
end
end)
One thing I see is that you aren’t assigning a debounce
to “AtDeskA” when it gets touched, this could be why perhaps?
Try doing this instead:
local sun = script.Parent
local DB = false
local humanoid = sun.Humanoid
humanoid:MoveTo(workspace.AtDeskA.Position)
game.Workspace.AtDeskA.Touched:Connect(function(hit)
if (hit.Parent:FindFirstChild("Humanoid")) and not DB then
DB = true
print(workspace.AtDeskA)
humanoid:MoveTo(workspace.AtDesk.Position)
humanoid.MoveToFinished:Wait()
humanoid:MoveTo(workspace.AtDesk2.Position)
humanoid.MoveToFinished:Wait()
DB = false
end
end)
:MoveTo() only moves the character to face one way then keep going that way. It doesn’t detect obstacles. You should be using PathfindingService.
Yes, but it could potentially fix this.
I wouldn’t exactly rely on adding a new Service to the mix though, even if it did work it’d probably just end up being more confusing & making the OP more complicated than what it needs to be
Another way you can detect for the MoveToFinished
event to fire is by setting its WalkToPart
property to the Part instead
Well in that case, it could be a bug. Is there any errors in the output? If there isn’t, try reporting it
I will try this script and comeback with answers as to how it goes.
As of right now it seems to work fine. I might comeback if there’s a problem again.
function walkTo(pos)
repeat
wait(0.3)
human.Humanoid:MoveTo(pos)
until (Vector3.new(pos.X,0,pos.Z) - Vector3.new(human.HumanoidRootPart.Position.X,0,human.HumanoidRootPart.Position.Z)).Magnitude <= 2
walkTo(Vector3.new(52, 50, 48))
walkTo(Vector3.new(158, 92, 145))
keep initiating to move to that position in case it breaks and until it close enough to target pos it will keep going to it i use this and works perfect for me even wit tons of locations
I could try this too if I encounter other problems. Thanks!