-
What do you want to achieve? I’m trying to set up a twitter code redeeming UI that gives the player x amount of points for redeeming each code.
-
What is the issue? I keep being received with the following error:
ServerScriptService.Server.Services.DataService:75: attempt to index nil with 'points'
- What solutions have you tried so far? Scripting isn’t my specialty, so I haven’t got much knowledge as to what to do here.
Here are the excerpts of what I believe is the relevant code:
The Code that is supposed to distribute the points (but with no success):
game.ReplicatedStorage.RedeemCode.OnServerInvoke = function(Player, Code, player)
local TwitterCodeStore = DataStoreService:GetDataStore("TwitterCodesStore2" .. Code)
local PlayerRedeemedCode = TwitterCodeStore:GetAsync(Player.UserId)
if TwitterCodes[Code] and not PlayerRedeemedCode then
print("redeemed!")
local AmountToGivePlayer = TwitterCodes[Code][2]
Knit.Services.DataService:addPoints(player, AmountToGivePlayer)
TwitterCodeStore:SetAsync(Player.UserId, true)
return true
else
return false
end
end
The Code that handles the redeeming system (and returns the abovementioned error):
RedeemButton.MouseButton1Click:Connect(function()
local Code = CodeBox.Text
local Redeemed = game.ReplicatedStorage.RedeemCode:InvokeServer(Code)
end)
The line that invokes the server is returning the error
But yeah would greatly appreciate if anybody could help me out with this issue. I’m happy to share more of the code if necessary but didn’t want to down right send the whole scripts bc of devforum rules.
Thanks