I already had a kill for cash script it work with the Roblox sword but it does not work with the sword I made.
I followed this tutorial to make the sword
How to make a Sword in Roblox Studio - YouTube
and I followed this tutorial to make the kill for cash script
How to make a Kill NPC For Cash Script ROBLOX Studio Tutorial - YouTube
here the script for the sword
local tool = script.Parent
local handle = tool:WaitForChild(“Handle”)
local holder = tool:WaitForChild(“Holder”)
local slash = script:WaitForChild(“Slash”)
local debounce = false
local playersHit = {}
for i, Parts in pairs(holder:GetChildren()) do
if Parts:IsA("MeshPart") then
local weld = Instance.new("WeldConstraint")
weld.Part0 = Parts
weld = holder
weld.Parent = Parts
end
end
tool.Activated:Connect(function()
if debounce == false then
debounce = true
local humanoid = tool.Parent:WaitForChild("Humanoid")
local AnimTrack = humanoid:LoadAnimation(slash)
AnimTrack:Play()
wait(1)
debounce = false
end
end)
holder.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent ~= tool.Parent then
if debounce == true and playersHit[Hit.Parent] == nil then
Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(10)
playersHit[Hit.Parent] = true
wait(1)
playersHit[Hit.Parent] = nil
end
end
end)
and here is the kill for cash script
local Humanoid = script.Parent.Humanoid
function Dead()
local tag = Humanoid:FindFirstChild(“creator”)
if tag ~= nil then
local leaderstats = tag.Value:FindFirstChild(“leaderstats”)
if leaderstats ~= nil then
leaderstats.Cash.Value = leaderstats.Cash.Value + 10
leaderstats.Kills.Value = leaderstats.Kills.Value + 1
wait(0.1)
script:Remove()
end
end
end
Humanoid.Died:Connect(Dead)