So, I made a custom sword which swings and does damage but, the problem is, it does not reward the player exp or money (denarii). I used the classic sword from the toolbox and it works fine so I don't see the problem.
Here is the sword damage script
local tool = script.Parent debounce = false tool.Activated:Connect(function() if debounce == false then debounce = true local dmg = script.Damage:Clone() dmg.Parent = script.Parent.Handle dmg.Disabled = false wait(.5) debounce = false if dmg then dmg:Destroy() end end end)
(this next script is inside of the previous script)
local weapon = script.Parent local dmg = 20 -- Damage weapon.Touched:Connect(function(part) if part.Parent:FindFirstChild("Humanoid") then -- Change "Enemy" to the humanoid you want to be killable local humanoid = part.Parent:FindFirstChild("Humanoid") -- Change the "Enemy" Again humanoid:TakeDamage(dmg) script:Destroy() end end)
Here is the reward script, it is placed inside of the enemy npc
local Humanoid = script.Parent.Humanoid -- User choice 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.Denarii.Value = Leaderstats.Denarii.Value + math.random(1,5) Leaderstats.Exp.Value = Leaderstats.Exp.Value + math.random(1,5) wait(0.1) script:remove() end end end end Humanoid.Died:connect(PwntX_X)
regardless what you try to do in 2nd or 3rd script,
why do you destroy the dmg script as soon as you created it?
if dmg then dmg:Destroy() end