I wanna make it so when my turret kills my zombie i get money I use this script for when i put it in the zombie and when i killed it i got cash
local Humanoid = script.Parent.turret1
function PwntX_X()
local tag = Humanoid:findFirstChild("creator")
if tag ~= nil then
if tag.Value ~= nil then
local Leaderstats = tag.Value:findFirstChild("leaderstats")
if Leaderstats ~= nil then
Leaderstats.Cash.Value = Leaderstats.Cash.Value + 1000000
wait(0.1)
script:remove()
end
end
end
end
Humanoid.Died:connect(PwntX_X)

3 comments
PwntX_X
first of all, indent your code
Use Destroy() instead of Remove, plus are you wanting to destroy the script because it clears the memory as well, did you just want to remove the creator tag? If this is a model you want to Destroy I’d recommend setting the parent to nil over using Destroy. Plus your leaderstats aren’t pathed right, plus some other stuff.