Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can modules not access players or whats wrong with this?

Asked by
Plieax 66
4 years ago

This is my module script, I would like to have one place where I can give players points that way I can notify them when they recieve it without needing to add the remote event and the cash adding stuff every time. This won't work though and I'm not sure why.

local cAdd = game.ReplicatedStorage.Remotes.CashAdd

local mod = {}

mod.addPts = function(plr,amt)
    plr:FindFirstChild("leaderstats").Points.Value = plr:FindFirstChild("leaderstats").Points.Value + amt
    cAdd:FireClient(plr)
end

return mod

Error

  12:49:02.237 - ServerScriptService.Mod:6: attempt to call method 'FindFirstChild' (a nil value)
12:49:02.237 - Stack Begin
12:49:02.237 - Script 'ServerScriptService.Mod', Line 6 - method addPts
12:49:02.238 - Script 'ServerScriptService.Remotes', Line 11
12:49:02.238 - Stack End

^ leaderstats does exsist in the player when this is called, the player also exsists

0
did you pass player as an argument? BlackOrange3343 2676 — 4y
0
Show how you call the function BlackOrange3343 2676 — 4y

Answer this question