So this code creates a wield between the player a part, however thought when you die the wield is supposed to be destoryed, but it isnt. No errors in output.

ALSO, when the script is destroyed in workspace and cloned back in workspace, the script dosent seem to create a wield anymore. Please help!

CODE:


local SIREN = game.Workspace.SirenHeadBot
SIREN.SirenHeadAI.Disabled = true
SIREN.Animate.Disabled = true

print("Teleport")
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Char)
local Part = Char:WaitForChild("HumanoidRootPart") 
local Weld = Instance.new("Weld", Char)
Part.Position = Vector3.new(game.Workspace.Knife.Position)
script.Parent.Knife.CFrame = Part.CFrame
Weld.Part0 = game.Workspace.Knife
Weld.Part1 = Part
Weld.C0 = Part.CFrame:inverse()
Weld.C1 = game.Workspace.Knife.CFrame:inverse()

end)
end)


game.Players.PlayerAdded:Connect(function(plr)
	
    plr.CharacterAdded:wait()
    plr.Character.Humanoid.HealthChanged:Connect(function()
        if plr.Character.Humanoid.Health <= 0
        then
            print("ded")
            SIREN.SirenHeadAI.Disabled = false
			SIREN.Animate.Disabled = false
			Weld:Destroy()
			
			
    end
end)
end)

6 comments

0

Does it print "ded" ?

0

The reason it may not work is because your connecting to an ongoing function which will continue to run after death try using :Disconnect at line 24

0

where do I put :disconnect?

0

Also try using a loop because when a player dies it will only do it once

0

well it dosent do it in the 1st place

0

Does it print ded