-
What do you want to achieve?
I want to have a model (imported from blender) to have a humanoid that can play animations and use WalkTo. -
What is the issue?
Right now, the model is not doing anything. No matter how much I try I can not get this thing to move without making it custom. Heres the script thats “working” but the model weirdly warps into the ground. While moving, it slides around on the floor and its almost like it’s being shoved into the ground. Here is my model structure, in case THAT is the issue (which is most likely is)
-
What solutions have you tried so far?
I have, and So far everything I’ve tried has not worked.
Here is the code i’m currently using (chatgpt - it’s the only thing that works currently), and this script has animation built in but it’s not working whatsoever.
local actualMonster = workspace:WaitForChild("ActualMonster")
local goToPart = workspace:WaitForChild("GoToPart")
local humanoidRootPart = actualMonster:WaitForChild("HumanoidRootPart")
local speed = 20 -- Increase this value for faster movement
local stopDistance = 5 -- Minimum distance to stop moving towards the target
local acceleration = 50 -- Speed up the model gradually
local currentSpeed = 0 -- Start speed at 0
-- Assuming the Humanoid exists in your ActualMonster model
local humanoid = actualMonster:FindFirstChildOfClass("Humanoid")
-- Check for Animator and create if missing
if not humanoid:FindFirstChildOfClass("Animator") then
local animator = Instance.new("Animator")
animator.Parent = humanoid
end
-- Create Animation objects
local walkAnimation = Instance.new("Animation")
walkAnimation.AnimationId = "rbxassetid://16291542714" -- Walk animation ID
local idleAnimation = Instance.new("Animation")
idleAnimation.AnimationId = "rbxassetid://16291550199" -- Idle animation ID
-- Load animations into the humanoid
local walkAnimationTrack = humanoid:LoadAnimation(walkAnimation)
local idleAnimationTrack = humanoid:LoadAnimation(idleAnimation)
game:GetService("RunService").Heartbeat:Connect(function(deltaTime)
local currentPosition = humanoidRootPart.Position
local targetPosition = goToPart.Position
local direction = (targetPosition - currentPosition).unit
local distanceToTarget = (targetPosition - currentPosition).magnitude
if distanceToTarget > stopDistance then
-- Accelerate towards the target
currentSpeed = math.min(currentSpeed + acceleration * deltaTime, speed)
local moveStep = direction * currentSpeed * deltaTime
humanoidRootPart.CFrame = CFrame.new(currentPosition + moveStep) * CFrame.Angles(0, math.atan2(-direction.X, -direction.Z), 0)
-- Play walk animation
if walkAnimationTrack.IsPlaying == false then
idleAnimationTrack:Stop()
walkAnimationTrack:Play()
end
else
currentSpeed = 0 -- Reset speed when close to target or stopped
-- Switch to idle animation
if idleAnimationTrack.IsPlaying == false then
walkAnimationTrack:Stop()
idleAnimationTrack:Play()
end
end
end)
Thank you in advance to anyone who responds! Thanks!