I have a simple datastore script that works fine but however it only works if player value is set to more than 0(or1) is there any ways to prevent this?
I figured this out by joining on my alt who never joined before.
Edit: Rejoining seems to fix this but why does it kick in the first place?
local DataStoreService = game:GetService("DataStoreService")
local playerData = DataStoreService:GetDataStore("playerData")
local __ISVIP = game:GetService("ReplicatedStorage"):FindFirstChild("__ISVIP")
--local __LOADED = game:GetService("ReplicatedStorage"):FindFirstChild("__VALUES"):FindFirstChild("__LOADED")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local TIX = Instance.new("IntValue")
TIX.Name = "TIX"
TIX.Value = 0
TIX.Parent = leaderstats
local REDEEM = Instance.new("NumberValue")
REDEEM.Name = "REDEEM"
REDEEM.Value = 0
REDEEM.Parent = player
local data = nil
local data2 = nil
local success, errormessage = pcall(function()
--task.spawn(function()
---- game:GetService("ServerStorage"):FindFirstChild(player.Name.. " Stuff").IsLoaded.Value = true
--end)
data = playerData:GetAsync(player.UserId.."-TIX", player.leaderstats.TIX.Value)
data2 = playerData:GetAsync(player.UserId.."-REDEEM", player.REDEEM.Value)
end)
if success and data ~= nil and data2 ~= nil then
TIX.Value = data
REDEEM.Value = data2
else
player:Kick("DATA COULDNT LOAD PLEASE REJOIN")
warn(errormessage)
end
end)