Basically I want that when I kill a monster, and you have my double money gamepass, it gives you the double money when you kill a monster. I have tried many different alternatives but it comes to no solution, pls help me
This is the code I have tried that is inside the zombie model and is a script not local script
local Humanoid = script.Parent.Humanoid local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local id = --gamepass id not sharing function died() local ms = game:GetService("MarketplaceService") local haspass = ms:UserOwnsGamePassAsync(Player.Userid, id) 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 +50 wait(0.1) script.remove() end end end end end end) Humanoid.Died:Connect(died)
local Humanoid = script.Parent.Humanoid local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local ToGive = 50 local id = --gamepass id not sharing local function died() local haspass = MarketplaceService:UserOwnsGamePassAsync(Player.Userid, id) local tag = Humanoid:FindFirstChild("creator") if tag ~= nil then if tag.Value ~= nil then local Leaderstats = tag.Value:FindFirstChild("leaderstats") if Leaderstats ~= nil then if haspass then Leaderstats.Cash.Value += (ToGive * 2) else Leaderstats.Cash.Value += ToGive end wait(.1) script.remove() end end end end) Humanoid.Died:Connect(died)