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!
Hello, i am new with DataStoreService, so i tried alone and without tutorials other than the from Roblox. -
What is the issue? Include screenshots / videos if possible!
Ok, so i am trying to make a IntroGui that will be played if a player was come in the Server the first time, but i don’t know why but it simply not store my boolean. I have a Textbutton, and when you press on it it will change a BooleanValue that it was located in a Folder. The problem was not on getting the data, but on saving it, then when i print out my Value with the MouseButton1Event it say me true, but when i stop to test in studio and see the output it say me false. Why? Really not understand and need help! -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Yes, but it the Topics i found not really helped me.
My script:
local DataStore = game:GetService("DataStoreService")
local CanBeginData = DataStore:GetDataStore("CanBegin")
local function CommonInstance(Type, Parent, Name)
local InstanceByFunc = Instance.new(Type)
InstanceByFunc.Parent = Parent
InstanceByFunc.Name = Name
return InstanceByFunc
end
game.Players.PlayerAdded:Connect(function(player)
local CanBeginValue
local function CanBeginnFunction() => boolean
CanBeginValue = CanBeginData:GetAsync(player.Name.."_CanBegin")
if CanBeginValue == nil then
CanBeginData:SetAsync(player.Name.."_CanBegin", false)
CanBeginValue = false
end
return CanBeginValue
end
local CanBeginnSuccess, CanBeginReturnValue = pcall(CanBeginnFunction)
print(player.Name.." has entred the game!")
if CanBeginnSuccess then
local MenuValues = game.ReplicatedStorage.States.MenuValues
local PlayerMenuValues = CommonInstance("Folder", MenuValues, player.Name.."'s MenuValues")
local CanBegin = CommonInstance("BoolValue", PlayerMenuValues, "CanBegin")
CanBegin.Value = CanBeginValue
else
print(CanBeginReturnValue)
player:Kick("Error message:"..CanBeginReturnValue..". For avoiding Datalost and others problems you will be disconnected. Sorry for this unexepted error and retry later else contact me.")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local CanBeginSucces, CanBeginReturnValue = pcall(function()
local MenuValues = game.ReplicatedStorage.States.MenuValues
CanBeginData:SetAsync(player.Name.."_CanBegin", MenuValues[player.Name.."'s MenuValues"].CanBegin.Value)
end)
end)