Script not detecting a part but the part is in explorer

I wanted to make a small thing that kills a player, and then randomly it doesn’t detect the part in there.

local TweenService = game:GetService("TweenService")
local killing = false

function kill(person)
    killing = true
    local humanoid = person:FindFirstChild("Humanoid")
    local humanoidRootPart = person:FindFirstChild("HumanoidRootPart")
    if humanoid and humanoidRootPart then
        humanoid.PlatformStand = true
        humanoidRootPart.Anchored = true
        TweenService:Create(script.Parent.Hand,TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.In),{CFrame = script.Parent.Hand.ToGoPos.CFrame}):Play()
        wait(1.5)
        local effect = script.Parent.Blood:Clone()
        person.Head.Neck:Destroy()
        effect.Parent = person.Head.NeckRigAttachment
        person.Head.CanCollide = true
        script.Parent.Hand.Kill:Play()
        TweenService:Create(script.Parent.Hand, TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {CFrame = script.Parent.Hand.MainPos.CFrame}):Play()
        wait(0.5)
        humanoid.PlatformStand = false
        humanoidRootPart.Anchored = false
    end
    killing = false
end

script.Parent.Trigger.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and not killing then
        if hit.Name == "Head" then
            kill(hit.Parent)
        end
    end
end)
1 Like

Is ToGoPos unanchored with CanCollide off? If it is, then it will just fall through the world and get destroyed. Same goes for it’s parent, Hand.

Make sure to check the Anchored property on each.

1 Like

Turns out that was the solution. Thank you.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.