Okay, so I'm somewhat new to scripting but I'm not a total "noob" at it. This script is placed inside my NPC and when it's killed it's supposed to give the player that killed the NPC EXP or double EXP depending upon if they own the game pass or not. Currently the whole script doesn't work can someone help me? So I have a similar script inside the NPC that also gives the player a "Kill" (This script works perfectly) but I'm pretty sure I broke the script when I was trying to add the game pass part onto it.
Code that's giving me trouble:
local Humanoid = script.Parent.Humanoid -- NPC Humanoid Name
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
amount = 50
id = 118972469
for i,v in pairs(game.Players:GetPlayers()) do
if v then
if game:GetService("MarketplaceService"):PlayerOwnsAsset(v,id) then
v.leaderstats.EXP.Value = v.leaderstats.EXP.Value + amount * 2
else
v.leaderstats.EXP.Value = v.leaderstats.EXP.Value + amount
wait(0.1)
script:remove()
end
end
end
end
Humanoid.Died:connect(PwntX_X)
Not sure if this is relevant, but the script that this code is based off of:
local Humanoid = script.Parent.Humanoid -- NPC Humanoid Name
function PwntX_X()
local tag = Humanoid:findFirstChild("creator")
if tag ~= nil then
if tag.Value ~= nil then
local Leaderstats = tag.Value:findFirstChild("PlayerStats")
if Leaderstats ~= nil then
Leaderstats.Kills.Value = Leaderstats.Kills.Value + 1
wait(0.1)
script:remove()
end
end
end
end
Humanoid.Died:connect(PwntX_X)

2 comments
Thank you for helping me. However, I'm still a bit confused as to where to place the script. Also, isn't the code source that you've provided meant to be broken up into separate scripts in different places. I'm sorry but I'm really not the best scripter and I'm still learning.
You are correct - if you look at the comments carefully, they were meant to be the guide on how to break it up. Lines 2-18 are a ModuleScript, up to line 25 is some alternate code for that ModuleScript, line 27 tells you where to put that ModuleScript, and the rest replaces the code you gave in the question.