Hello, I want to make a script save data of a Boolean value but don’t know how to do that what I done Is followed AlvinBlox’s datastore tutorial and it worked for other things regarding values in the player not in the object itself.
game.Players.PlayerAdded:Connect(function(player)
local Own = script.Parent.Own
local data
local success, errormessage = pcall(function()
data = WeaponData:GetAsync(player.UserId.."-Own")
end)
if success then
Own.Value = data
else
print("Error in storage detected")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local Own = script.Parent.Own
local success, errormessage = pcall(function()
WeaponData:SetAsync(player.UserId.."-Own",script.Parent.Own.Value)
end)
if success then
print("Player data successfuly stored")
else
print("Failed")
warn(errormessage)
end
end)
That’s the problem, Datastores only work on the server, consider moving it to the ServerScriptService instead. which means you’ll have to reference Own differently using the player argument.(passed trough the playeradded and removing events)
I think this is better way to make datastore, Documentation - Roblox Creator Hub
Actually, you can add more values to one datastore, but that’s just my opinion.