Hello, I have made a shop system which uses a currency known as skill points. For some reason, when I do a server test outside of game the script works fine, however when I actually play the game it gives me a nil value for the function that takes away skill points after a purchase.
event.OnServerEvent:connect(function (player, ...) if player ~= nil then local tuple = {...} if tuple[1] == "Buy" then if tuple[2] == "KillerChance" then local mydata = playerdata[player.userId] if mydata ~= nil and mydata.skillpoints >= 5 then local price = -5 awardskillpoints(player, price) mydata.killerchance = mydata.killerchance + 1 local killerchancevalue = player:WaitForChild("Killer Chance") if killerchancevalue ~= nil then killerchancevalue.Value = mydata.killerchance end end elseif tuple[2] == "OfficerChance" then local mydata = playerdata[player.userId] if mydata ~= nil and mydata.skillpoints >= 5 then local price = -5 awardskillpoints(player, price) mydata.officerchance = mydata.officerchance + 1 local officerchancevalue = player:WaitForChild("Officer Chance") if officerchancevalue ~= nil then officerchancevalue.Value = mydata.officerchance end end elseif tuple[2] == "100Points" then end end end end)
where it says awards skillpoints, it gives me a nil when actually in the game.
It says awarskillpoints is a nil or something like that.
here is the function
function awardskillpoints(player, skillpoints) if player ~= nil and skillpoints ~= nil and skillpointdebounce == false then skillpointdebounce = true local mydata = playerdata[player.userId] if mydata ~= nil then mydata.skillpoints = mydata.skillpoints + skillpoints local skillpointsvalue = player:WaitForChild("Skill Points") if skillpointsvalue ~= nil then skillpointsvalue.Value = mydata.skillpoints delay(0.00000000000000000000001, function () skillpointdebounce = false end) end end end end end
I'm not sure what could possibly be wrong. Please help.
Thank you in advance.