Attempt to index nil with waitforchild on npc here's my code
local Player = game.Players.LocalPlayer local Leaderstat = Player:WaitForChild("leaderstats") local Humanoid = script.Parent.Humanoid function Dead() Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value + 100 wait(0.1) script:remove() end Humanoid.Died:connect(Dead)
You cant access LocalPlayer
with a server script.
local Humanoid = script.Parent.Humanoid function Dead() for _, player in pairs(game.Players:GetPlayers()) do --Gets all players local Leaderstat = player:WaitForChild("leaderstats") Leaderstats.Cash.Value = Leaderstats.Cash.Value + 100 end wait(0.1) script:Remove() end Humanoid.Died:connect(Dead)
Hope it helps
Closed as Not Constructive by User#32819, CreationNation1, Dovydas1118, and WideSteal321
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?