Why my script doesn't attract me after death?
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()
local mouse = plr:GetMouse()
local distance = 100 -- ????????? ?? ??????? ??????? ???????
local debounce = true
script.Parent.Activated:Connect(function(player)
local att0 = Char.HumanoidRootPart:WaitForChild("Attachment")
local Mpos = mouse.Hit.Position
local comparison = (Char.HumanoidRootPart.Position - Mpos).Magnitude
if comparison <= distance then
if debounce == true then
local Hook = Instance.new("Part",game.Workspace)
local att = Instance.new("Attachment",Hook)
local spring = Instance.new("BallSocketConstraint",Hook)
spring.Name = "ball"
spring.Attachment0 = att0
spring.Attachment1 = att
Hook.Name = "Hook"
Hook.Size = Vector3.new(1,1,1)
Hook.Anchored = true
Hook.CanCollide = false
Hook.Position = Mpos
if mouse.Target.Parent:FindFirstChild("Humanoid") then
mouse.Target.Parent.Humanoid:TakeDamage(20)
end
debounce = false
Hook.Touched:Connect(function(Chars)
if Chars.Parent:FindFirstChild("Humanoid") then
--Char:MoveTo(Hook.Position)
Hook:Destroy()
debounce = true
end
end)
Char.Humanoid.HealthChanged:Connect(function()
if Char.Humanoid.Health <= 0 then
spring.Attachment0 = nil
Hook:Destroy()
debounce = true
end
end)
end
end
end)