I tried a lot of MoveTo examples but nothing worked. Can someone tell me why and fix my Crab?
Crab Model:
Model Not Aviable Anymore.
Here is Crab Script:
local PATROL_DELAY = 7
local crab = game.Workspace.CrabsAndShels.Crab1
local humanoid = crab.Humanoid
local pointA = game.Workspace.CrabsAndShels.CrabPoints.Point1
local pointB = game.Workspace.CrabsAndShels.CrabPoints.Point2
local nextDestinationObject = pointA
while wait(PATROL_DELAY) do
humanoid:MoveTo(nextDestinationObject.Position)
humanoid.MoveToFinished:Wait()
if nextDestinationObject == pointA then
nextDestinationObject = pointB
else
nextDestinationObject = pointA
end
end
Did not look at the demo. Does your model have a PrimaryPart set? That is what MoveTo actually moves.
EDIT: Also a protip, when posting for help try to make it easy for people to help you. Maybe post screenshots or snippets of code instead of the game. Loading up studio is quite the hassle.
You mean Model:MoveTo() or Humanoid:MoveTo()? I would suggest using Model:SetPrimaryPartCFrame() if you’re using Model:MoveTo(). If your :MoveTo() is a Humanoid:MoveTo() then check if the HumanoidRootPart is anchored or not. It can’t move if it’s anchored.
I did but @Awesom3_Eric didn’t know how everything works so I replaced code and Crab Explorer Structure to Crab Demo Model.
Also what do you mean by Setting Primary Part (I know how to set Primary Part but I dont know what should I set as Primary Part).
I don’t think a Humanoid will work in this situation as there are only 2 parts. Here’s why. I think you need at least 6 parts, names corrospondingly for the humanoid to work. I’m not too sure but this is what the DevHub says.
Just a guess, but this happens A LOT when I’m working even with just rigs - anchor, and then unanchor everything in the model by using the anchor button when selecting the model. Who knows, but it usually works for me when it hasn’t worked.
Script doesn’t error. I unanchored the Crab and still nothing.
Also Model:MoveTo() works, but I don’t want to use it. I want to use Humanoid:MoveTo() to make Crab walking not Teleporting.
Please look at the Model too and check what’s wrong with it (why it doesn’t move at all).
local tweenService = game:GetService("TweenService")
local PATROL_DELAY = 7
local MOVE_DURATION = 3
local crab = game.Workspace.CrabsAndShels.Crab1
local pointA = game.Workspace.CrabsAndShels.CrabPoints.Point1
local pointB = game.Workspace.CrabsAndShels.CrabPoints.Point2
local humanoid = crab.Humanoid
local nextDestinationObject = pointA
for _, part in ipairs(crab:GetDescendants()) do
if part ~= crab.PrimaryPart and part:IsA("BasePart") then
local Weld = Instance.new("WeldConstraint")
Weld.Part0 = part
Weld.Part1 = crab.PrimaryPart
Weld.Parent = crab.PrimaryPart
part.Anchored = false
end
end -- Weld All Parts Together to Tween Primary Part
local function moveCrab(toPart)
tweenService:Create(crab.PrimaryPart, TweenInfo.new(MOVE_DURATION), {CFrame = toPart.CFrame}):Play()
end -- Move Crab using Tween Service
local start = tick()
game:GetService("RunService").Heartbeat:Connect(function()
if tick() - start >= PATROL_DELAY then
moveCrab(nextDestinationObject)
if nextDestinationObject == pointA then
nextDestinationObject = pointB
else nextDestinationObject = pointA
end
start = tick()
end
end) -- Move Crab using Heartbeat rather that While wait() Loop (because it's bad lol)
Thanks! I have a question? How would it be possible to move the Crab towards the Player or move it Randomly? If you don’t want to answer or you don’t know how to do it etc. don’t Reply.