I got this nifty little script for my tool, and modified it a little to match my preferences. Only problem with the gear is that it doesn't give the player a kill after ending another players life. Any ideas? I tested it with an NPC, and 2 players, but doesn't bump the kill count. Thank you!
~~~~~~~~~~~~~~~~~
local tool = script.Parent local canDamage = false local function onTouch(otherPart) local humanoid = otherPart.Parent:FindFirstChild("Humanoid") if not humanoid then return end if humanoid.Parent ~= tool.Parent and canDamage then humanoid:TakeDamage(100) else return end canDamage = false end local RESET_SECONDS = .8 local isTouched = false -- Declare debounce variable local function slash() if not isTouched then -- Check that debounce variable is not true isTouched = true -- Set variable to true local str = Instance.new("StringValue") str.Name = "toolanim" str.Value = "Slash" str.Parent = tool canDamage = true wait(RESET_SECONDS) -- Wait for reset time duration isTouched = false -- Reset variable to false print("slash") end end tool.Activated:Connect(slash) tool.Handle.Touched:Connect(onTouch)
~~~~~~~~~~~~~~~~~
just add a check for leaderstats and increase the value
local plr = game.Players:GetPlayerFromCharacter(tool.Parent) or tool.Parent.Parent -- if tool is equipped parent will be character, if tool is not equipped parent will be backpack and backpack is parented to the player if plr then local stats = plr:FindFirstChild("leaderstats") if stats then local kills = stats.Kills -- or whatever the kills are kills.Value += 1 end end
BTW this would be in the part of your script after the humanoid took 100 Damage