I watched a tutorial on youtube where he adds it on “else” but when i added Sword:Destroy() it did not destroy it when it touched the floor
Sword.Touched:Connect(function(Hit)
if Hit:IsA("BasePart") then
if not Hit:IsDescendantOf(Char) then
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
Humanoid:TakeDamage(5)
Sword:Destroy()
else
end
end
end
end)
You put Sword:Destroy() in the wrong spot. Here is a correct script:
Sword.Touched:Connect(function(Hit)
if Hit:IsA("BasePart") then
if not Hit:IsDescendantOf(Char) then
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
Humanoid:TakeDamage(5)
else
Sword:Destroy()
end
end
end
end)
Should it be destroyed when it hits a player as well as when it hits the floor?
If so:
Sword.Touched:Connect(function(Hit)
if Hit:IsA("BasePart") then
if not Hit:IsDescendantOf(Char) then
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
Humanoid:TakeDamage(5)
Sword:Destroy()
else
Sword:Destroy()
end
end
end
end)