I got something working but its not killing the other player also not killing me
Here is the script:
Part.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid and hit.Parent ~= tool.Parent and not hit.Parent:IsDescendantOf(plr) then
humanoid.Health -= 12
end
end)
this is a method I tried using but it doesn’t kill the other players and i also take no damage which is good but i want the other {players} to take damage
here is a example of what is happening when i unequip the tool
oh yeah sorry about that i thought people would know that I can get the player from the tool by using
game.Players:GetPlayerFromCharater(tool.Parent)
tool.Activated:Connect(function()
local plr = game.Players:GetPlayerFromCharacter(tool.Parent)
if os.clock() > clock then
clock = os.clock() + DeTime
local Part = makePart(plr) -- i returned a part from this function
Part.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid and hit.Parent ~= tool.Parent and not hit.Parent:IsDescendantOf(plr) then
humanoid.Health -= 12
end
end)
end
end)
part.Touched:Connect(function(hit)
local humanoid = hit .Parent:FindFirstChild("Humanoid")
if humanoid and humanoid ~= plrHumanoid then
humanoid:TakeDamage(30)
print(hit.Parent)
end
end)
The issue was when the tool was Unequipped the tool.Parent will no longer be the Current player
so i stored it in a variable and compared the humanoid to the plrHumanoid instead of hit.Parent