-
What do you want to achieve?
An AI that doesn’t slide around the ground -
What is the issue?
The Character is Sliding and I don’t have any idea how to fix it. -
What solutions have you tried so far?
I did look on the DevHub but didn’t find anything,
I tried changing the HipHeight
Changing Platform Stand to true [Made it worse so I changed it back]
Setting all the parts to CanCollide = false
Currently the HumanoidRootPart is not anchored like every other Part, Otherwise it wouldn’t move.
Also Here’s the AI Code:
local teddy = script.Parent
local humanoid = teddy.Humanoid
local waypoints
local nextWaypointIndex
local reachedConnection
local blockedConnection
humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
for i, player in ipairs(game.Players:GetPlayers()) do
script.Parent.HumanoidRootPart:SetNetworkOwner(player)
end
local PathfindingService = game:GetService("PathfindingService")
local function getPath(destination)
local pathParams = {
["AgentHeight"] = 3,
["AgentRadius"] = 1.5,
["AgentCanJump"] = true,
["AgentCanClimb"] = true,
}
local path = PathfindingService:CreatePath(pathParams)
for _, part in pairs(script.Parent:GetChildren()) do
if part:IsA("BasePart") then
part:SetNetworkOwner(nil)
end
end
local waypointss = path:GetWaypoints()
--
path:ComputeAsync(teddy.HumanoidRootPart.Position, destination.Position)
path.Blocked:Connect(function()
print("Path is blocked, Generating new Path..")
path:ComputeAsync(teddy.HumanoidRootPart.Position, destination.Position)
end)
--
for _, part in pairs(script.Parent:GetChildren()) do
if part:IsA("BasePart") then
part:SetNetworkOwner(nil)
end
end
return path
end
local function walkTo(destination)
local path = getPath(destination)
for _, part in pairs(script.Parent:GetChildren()) do
if part:IsA("BasePart") then
part:SetNetworkOwner(nil)
end
end
for index, waypoint in pairs(path:GetWaypoints()) do
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
end
end
local function patrol()
for _, part in pairs(script.Parent:GetChildren()) do
if part:IsA("BasePart") then
part:SetNetworkOwner(nil)
end
end
local waypoints = workspace.IMPORTANTSCRIPTING.TrashRobotSpots:GetChildren()
local randomNum = math.random(1, #waypoints)
walkTo(waypoints[randomNum])
end
local Anims = script.Parent.Anims.Uploaded
local Spots = game.Workspace.IMPORTANTSCRIPTING.TrashRobotSpots
local Torso = script.Parent.Torso
local Root = script.Parent.HumanoidRootPart
local Sounds = script.Parent.Head.Sounds
wait(1)
patrol()
while wait(3) do
if script.Parent.Scripting.IsInTalk.Value == 0 then
local Randomizer = math.random(1,5)
if Randomizer == 1 then
walkTo(Spots.Trash1)
wait(0.2)
Torso.CFrame = Spots.Trash1.CFrame
Root.Anchored = true
script.Parent.Humanoid:LoadAnimation(Anims.CollectTrash):Play()
Sounds.TrashMotor:Play()
wait(2)
Spots.Trash1.Icosphere.Transparency = 1
Sounds.TrashMotor2:Play()
script.Parent.Head.ProximityPrompt.Enabled = true
script.Parent.Humanoid:LoadAnimation(Anims.CollectTrash):Stop()
Root.Anchored = false
wait(7)
Spots.Trash1.Icosphere.Transparency = 0
script.Parent.Head.ProximityPrompt.Enabled = false
end
if Randomizer == 2 then
walkTo(Spots.Trash2)
wait(0.2)
Torso.CFrame = Spots.Trash2.CFrame
Root.Anchored = true
script.Parent.Humanoid:LoadAnimation(Anims.CollectTrash):Play()
Sounds.TrashMotor:Play()
wait(2)
Root.Anchored = false
Spots.Trash2.Icosphere.Transparency = 1
Sounds.TrashMotor2:Play()
script.Parent.Head.ProximityPrompt.Enabled = true
script.Parent.Humanoid:LoadAnimation(Anims.CollectTrash):Stop()
wait(7)
Spots.Trash2.Icosphere.Transparency = 0
script.Parent.Head.ProximityPrompt.Enabled = false
end
if Randomizer == 3 then
walkTo(Spots.Trash3)
wait(0.2)
Torso.CFrame = Spots.Trash3.CFrame
Root.Anchored = true
script.Parent.Humanoid:LoadAnimation(Anims.CollectTrash):Play()
Sounds.TrashMotor:Play()
wait(2)
Root.Anchored = false
Spots.Trash3.Icosphere.Transparency = 1
Sounds.TrashMotor2:Play()
script.Parent.Head.ProximityPrompt.Enabled = true
script.Parent.Humanoid:LoadAnimation(Anims.CollectTrash):Stop()
wait(7)
Spots.Trash3.Icosphere.Transparency = 0
script.Parent.Head.ProximityPrompt.Enabled = false
end
if Randomizer == 4 then
walkTo(Spots.Trash4)
wait(0.2)
Torso.CFrame = Spots.Trash4.CFrame
Root.Anchored = true
script.Parent.Humanoid:LoadAnimation(Anims.CollectTrash):Play()
Sounds.TrashMotor:Play()
wait(2)
Root.Anchored = false
Spots.Trash4.Icosphere.Transparency = 1
Sounds.TrashMotor2:Play()
script.Parent.Head.ProximityPrompt.Enabled = true
script.Parent.Humanoid:LoadAnimation(Anims.CollectTrash):Stop()
wait(7)
Spots.Trash4.Icosphere.Transparency = 0
script.Parent.Head.ProximityPrompt.Enabled = false
end
if Randomizer == 5 then
walkTo(Spots.Trash5)
wait(0.2)
Torso.CFrame = Spots.Trash5.CFrame
Root.Anchored = true
script.Parent.Humanoid:LoadAnimation(Anims.CollectTrash):Play()
Sounds.TrashMotor:Play()
wait(2)
Root.Anchored = false
Spots.Trash5.Icosphere.Transparency = 1
Sounds.TrashMotor2:Play()
script.Parent.Head.ProximityPrompt.Enabled = true
script.Parent.Humanoid:LoadAnimation(Anims.CollectTrash):Stop()
wait(7)
Spots.Trash5.Icosphere.Transparency = 0
script.Parent.Head.ProximityPrompt.Enabled = false
end
else
print("Not Available cuz Talking to Player!")
end
end
Maybe you can Help