There are no errors in the out put and I dont know why it does not work. I found it on youtube, heres the script
local hum = script.Parent.Humanoid hum.Died:Connect(function() local tag = hum:FindFirstChild("creator") if tag ~= nil then if tag.Value ~= nil then local lstats = tag.Value.leaderstats lstats.Gold.Value = lstats.Gold.Value +10 lstats.Experience.Value = lstats.Experience.Value +3 end end end)
Not sure but I think you have to do this way differently. I would do something like
local hum = script.Parent.Humanoid hum.Died:Connect(function(player) player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 10 player.leaderstats.Experience.Value = player.leaderstats.Experience.Value + 3 end)
But make sure the leaderstats actually exists. Something similar to that. If it doesn't work I think you need to add some script to the weapon to find the player who killed the NCP. If it's a player, not an NCP then try putting the script in startercharacterscripts. Otherwise, you need to add some code to the weapon. Edit: Use this kind of leaderstats
local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("CashSaveSystem") game.Players.PlayerAdded:connect(function(player) local leader = Instance.new("Folder",player) leader.Name = "leaderstats" local Cash = Instance.new("IntValue",leader) Cash.Name = "Cash" Cash.Value = ds:GetAsync(player.UserId) or 0 ds:SetAsync(player.UserId, Cash.Value) Cash.Changed:connect(function() ds:SetAsync(player.UserId, Cash.Value) end) end)