AI spinning out of control

When my AI kills someone, they spin out of control and won’t stop, ever…

1 Like

Idk what’s happening there but that’s really funny.

Anyway we can’t help you with this if you provide no code.

he’s just spinning after brutally killing the guy
reminds me of that one “speeeen” meme lol

2 Likes

I don’t think it’s a script problem because there is another AI that is smaller and doesn’t spin

but here

local Dummy = script.Parent.Parent
local animKill = script.Parent.Parent:FindFirstChild(“Humanoid”):LoadAnimation(script.Parent.Parent.Swing)

local bs = game:GetService(“BadgeService”)

local id = 3087677870210396

debounce = false

Dummy.Hitbox.Touched:Connect(function(IsAPlayer)
if debounce == false then
if IsAPlayer.Parent:FindFirstChild(“Humanoid”) and IsAPlayer.Parent.Name ~= “SentinelWhite” and IsAPlayer.Parent.Name ~= “SentinelBlack” and IsAPlayer.Parent.Humanoid.Health ~= 0 and not IsAPlayer.Parent:FindFirstChild(“Helper”) and not IsAPlayer.Parent:FindFirstChild(“InJumpscare”) then
animKill:Play()
local player = game.Players:GetPlayerFromCharacter(IsAPlayer.Parent)
bs:AwardBadge(player.UserId, id)
debounce = true
game.ReplicatedStorage.TIOAttackCamera:FireClient(player, Dummy.Camera)
local InJumpscare = Instance.new(“BoolValue”, IsAPlayer)
InJumpscare.Name = “InJumpscare”
IsAPlayer.Parent.HumanoidRootPart.Anchored = true
Dummy.HumanoidRootPart.Ambience.Playing = false
wait(1)
Dummy.HumanoidRootPart.Jumpscare:Play()
Dummy.HumanoidRootPart.Anchored = true
wait(5)
Dummy.HumanoidRootPart.HitSound:Play()
if IsAPlayer then
IsAPlayer.Parent.HumanoidRootPart.Anchored = false
IsAPlayer.Parent.Humanoid.Health = 0
end
wait(3)
Dummy.HumanoidRootPart.Ambience.Playing = true
Dummy.HumanoidRootPart.Anchored = false
debounce = false
end
end
end)

I don’t think I can help you with that, this script requires a whole rewrite from scratch.

Again, it’s not a script problem. There is another AI that doesn’t spin when they killed someone and it’s the same script.

maybe it has something to do with the mesh / HRP tampering?

Possibly something like this then?
Definetly something to do with the humanoid tho.

Maybe because it’s flying, maybe because it’s too big.

What are the masses of the large and small AIs?

When you copy/paste code here you can format it correctly just by typing 3 backticks before and after the code. It’ll write it here exactly as it looks in Studio. Please edit the post with the code above so it’s easier for us to read.

What is the code that is moving the AI? Seems more like a movement issue than an Animation issue.

Check the AI’s AssemblyLinearVelocity and AssemblyAngularVelocity before and after the spinning starts. You may have inserted a force that’s causing the spin in some other section of code.

local RunService = game:GetService("RunService")

RunService.Heartbeat:Connect(function()
	local nearestPlayer
	local minDistance = math.huge

	for _, player in pairs(game:GetService("Players"):GetPlayers()) do
		local distance = (script.Parent.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).Magnitude

		if distance < minDistance then
			minDistance = distance
			nearestPlayer = player
		end
	end

	if nearestPlayer then
		local path = PathfindingService:CreatePath()

		path:ComputeAsync(script.Parent.HumanoidRootPart.Position, nearestPlayer.Character.HumanoidRootPart.Position)

		local waypoints = path:GetWaypoints()
		for i = 1,#waypoints do
			script.Parent.Humanoid:MoveTo(waypoints[i].Position)
			script.Parent.Humanoid.MoveToFinished:Wait()
		end

	end
end)

movement code.

It might be this line:
script.Parent.Humanoid.MoveToFinished:Wait()
If the player dies before the MoveToFinished:Wait() I’m pretty sure it’ll get stuck waiting there.
A simple check would be to put

		for i = 1,#waypoints do
			script.Parent.Humanoid:MoveTo(waypoints[i].Position)
            print("MoveTo Started")
			script.Parent.Humanoid.MoveToFinished:Wait()
            print("MoveTo Finished")
		end

If the Started one prints and the player dies the Finished one might never print.

1 Like