So what im trying to here is once i join a game i want the boolvalue to be true at first but after the person leaves I want the boolvalue to be false and i want it to be false forever but everytime I join it keeps on printing true
local datastore = game:GetService("DataStoreService")
local FirstOrNotDataStore = datastore:GetDataStore('FirstOrNot')
game.Players.PlayerAdded:Connect(function(plr)
local folder = Instance.new("Folder")
folder.Name = 'FirstOrNot'
folder.Parent = plr
BoolValue = Instance.new("BoolValue")
BoolValue.Parent = folder
BoolValue.Value = FirstOrNotDataStore:GetAsync(plr.UserId) or true
print(BoolValue.Value)
end)
game.Players.PlayerRemoving:Connect(function(plr)
BoolValue.Value = false -- set it to false
BoolValue.Value = FirstOrNotDataStore:SetAsync(plr.UserId, BoolValue.Value) -- set it to false forever for the rest of eternity
end)

1 comment
The key to a datastore must be a string. The UserId of the player is an int64. I've had issues with this in the past where it didn't display an error. Just use tostring or something similar.