The title says all but. I am trying to give players depends on the npc they killed
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local ServerScriptService = game:GetService("ServerScriptService")
local Npc = script.Parent
local NPCHumanoid = Npc:WaitForChild("Humanoid")
local NpcModule = require(ServerScriptService.NPCs)
if NPCHumanoid then -- Checks Humanoid
NPCHumanoid.Died:Connect(function()
print("Test1")
local npcTagger = NPCHumanoid.Montaigne.Value
if npcTagger ~= nil then --Check the tag
print("Test2")
local player = game:GetService("Players"):GetPlayerFromCharacter(npcTagger)
print(player.Name)
if player then
print("Test3")
for i , v in pairs(NpcModule) do
player.leaderstats.Coins += v.Coins
end
end
end
end)
end
this is the module script
it doesn’t print player.Name and Test3
it gives 400 coins even if player just kills the “Noob” npc