So basically im trying to make a user friendly settings module and make the function set a players cash to the starting cash amount inside of the function, startingcash in the module script. It should be a simple fix but im stupid so i need help!, Thanks
Module
local module = {} function startingcash(player) local startingcashamount = 10 -- Replace this number with starting cash amount!-- player.leaderstats.Cash.Value = startingcashamount end return module
ServerScript
game.Players.PlayerAdded:connect(function(plr) local leader = Instance.new("Folder",plr) leader.Name = "leaderstats" local cash = Instance.new("NumberValue",leader) cash.Name = "Cash" gamesettings.startingcash(plr) end)
Error Inside of Serverscript: "00:30:33.496 - Workspace.Plieax's Tycoon Kit.Main Scripts.leaderboard:13: attempt to call field 'startingcash' (a nil value)"
Line 1 of your server script. It’s :Connect, not :connect.
Line 2 of your module script should be:
function module.startingcash(player) -- OR function module:startingcash(player)
Put the module script data inside the curly bracket things whatever they're called again.
local module = { function startingcash(player) local startingcashamount = 10 -- Replace this number with starting cash amount!-- player.leaderstats.Cash.Value = startingcashamount end } return module
And your server script is even more messed up. Can you post more of it here please? Specifically up to line 13 where it errors. For one, you need to call modules with require()
gamesettings = require(PathToFindModuleScriptHere) -- should be self explanatory. local leader = Instance.new("Folder",plr) leader.Name = "leaderstats" local cash = Instance.new("NumberValue",leader) cash.Name = "Cash" gamesettings.startingcash(plr)