You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
Make it so the script functions properly
What is the issue? Include screenshots / videos if possible!
Line that keeps giving the error:
Information = HttpService:JSONDecode(Information.Data)
The DatastoreUpdate Function:
function _G:DatastoreUpdate(FuncInformation,Update)
local Player = FuncInformation.Player
local Key = Player.UserId
local Information = ArrestDatastore:GetAsync(Key)
local Sentence = 0
local Threshold = 15
if Information == nil then
Information = {
Sentence = 0
}
ArrestDatastore:SetAsync(Key,HttpService:JSONEncode(Information))
end
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Uhhh, I added in Information.Data so it gets rid of the String error that kept giving me an error.
function _G:DatastoreUpdate(FuncInformation,Update)
local Player = FuncInformation.Player
local Key = Player.UserId
local Information = ArrestDatastore:GetAsync(Key)
local Sentence = 0
local Threshold = 15
local Information = nil
if Information == nil then
Information = {
Sentence = 0
}
ArrestDatastore:SetAsync(Key,HttpService:JSONEncode(Information))
end
Information = HttpService:JSONDecode(Information.Data)
if Information.Sentence ~= 0 or FuncInformation.Sentence then
if FuncInformation.Sentence ~= nil then
Information.Sentence = Information.Sentence + FuncInformation.Sentence
ArrestDatastore:SetAsync(Key,HttpService:JSONEncode(Information))
end
function _G:DatastoreUpdate(FuncInformation,Update)
local Player = FuncInformation.Player
local Key = Player.UserId
local Information = ArrestDatastore:GetAsync(Key)
local Sentence = 0
local Threshold = 15
local Information = nil
if Information then
Information = HttpService:JSONDecode(Information)
else
Information = {
Sentence = 0
}
ArrestDatastore:SetAsync(Key,HttpService:JSONEncode(Information))
end
if Information.Sentence ~= 0 or FuncInformation.Sentence then
if FuncInformation.Sentence ~= nil then
Information.Sentence = Information.Sentence + FuncInformation.Sentence
ArrestDatastore:SetAsync(Key,HttpService:JSONEncode(Information))
end
This is because you were JsonDecoding no matter if it was decoded or not, if you move it into the if statement it will only decode if it’s coming directly from the datastore.
function _G:DatastoreUpdate(FuncInformation,Update)
local Player = FuncInformation.Player
local Key = Player.UserId
local Information = ArrestDatastore:GetAsync(Key)
local Sentence = 0
local Threshold = 15
local Information = nil
if Information == nil then
Information = {
Sentence = 0
}
ArrestDatastore:SetAsync(Key,HttpService:JSONEncode(Information))
end
Information = HttpService:JSONDecode(Information.Data)
if Information.Sentence ~= 0 or FuncInformation.Sentence then
if FuncInformation.Sentence ~= nil then
Information.Sentence = Information.Sentence + FuncInformation.Sentence
ArrestDatastore:SetAsync(Key,HttpService:JSONEncode(Information))
end
game.Players.PlayerAdded:Connect(function(Player) -- line 92
local PushTable = { -- line 93
Player = Player -- line 94
} -- line 95
_G:DatastoreUpdate(PushTable) -- line 96
end) -- line 97
game.Players.PlayerAdded:Connect(function(Player) -- line 92
local PushTable = { -- line 93
Player = Player -- line 94
} -- line 95
_G:DatastoreUpdate(PushTable) -- line 96
end) -- line 97