Put this inside the tool instance itself (not the part, the tool) as a normal script (not a local or module)
local tool = script.Parent
local currentime = 0
local timend = 5
function toolEquipped()
begin()
end
tool.Equipped:connect(toolEquipped)
local db = 0
function begin()
if db == 0 then
db = 1
function getHumanoid()
local affirmative = false
local hmd
if tool.Parent:IsA("Model") then
hmd = tool.Parent:FindFirstChild("Humanoid")
if hmd then
affirmative = true
end
end
if affirmative == true then
return hmd
else
return nil
end
end
local humanoid
repeat
humanoid = getHumanoid()
if humanoid == nil then
else
currentime = currentime + 0.1
end
wait(0.1)
until currentime >= timend
humanoid.Health = 0
end
end
This script however will not make anything die if it's not equipped by a player.
But I did make it so it will only do the counting only IF equipped by a humanoid/player.
1 comment
Lua, not LUA.