Hey, I am making an inventory, but I’m stuck with a problem I made this script in serverscriptservice, which saves a BoolValue. (this script works)
local DataStoreService = game:GetService("DataStoreService");
local DataStore = DataStoreService:GetDataStore("BannedDataStore");
game.Players.PlayerAdded:Connect(function(player)
local boolval = Instance.new("BoolValue", player)
boolval.Value = DataStore:GetAsync(player.UserId) or false
if boolval.Value == true then
print("Player value is true.")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
DataStore:SetAsync(player.UserId, player:FindFirstChild("Value").Value)
end)
This script saves the value. I also made this script in my frame, because I want a frame visible when the value is set to true.
local DataStoreService = game:GetService("DataStoreService");
local DataStore = DataStoreService:GetDataStore("BannedDataStore");
game.Players.PlayerAdded:Connect(function(player)
local boolval = Instance.new("BoolValue", player)
boolval.Value = DataStore:GetAsync(player.UserId) or false
if boolval.Value == true then
print("Player value is true.")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
DataStore:SetAsync(player.UserId, player:FindFirstChild("Value").Value)
end)
I’ve also tried this script in a textbutton, and changed the first line correctly, but that didn’t work. I don’t know why this doesn’t work and I really need this.
Thanks for reading this, have a nice day!