Datastore saving boolvalues help

Hey,

I don’t have a single clue on how to make Datastores or even work with them.

I’m trying to make something where if you buy something ingame with ingame cash, it’ll change a Boolvalue thats in a folder in Starterplayer to True.

I want to make it so when you leave, that true statement stays true since you bought the item.

How do I make a datastore script that saves the true/false statements in Starterplayer folder?
image
image

1 Like

I need to get this done today, could someone please help me make a short and simple script to save the value of true/false?

1 Like

I have no ideas on how to use datastores, and its hard to find answers. i have 30 minutes until my deadline is here. I must get this shop out soon.

1 Like

Please do not ask people to write entire scripts or design entire systems for you. If you can't answer the three questions above, you should probably pick a different category.
Please Stop, i am willing to help but please follow the rules
Here is a script that someone made a while ago: (Credit: Kaid3n22)

local DataStore = game:GetService("DataStoreService") -- Data Store Service
local DS = DataStore:GetDataStore("Data") -- Creates a DataStore

local Players = game:GetService("Players")

local PGP = {} -- Purchased Game passes

Players.PlayerAdded:Connect(function(plr)
local Data = DS:GetAsync(plr.UserId, PGP[plr.UserId]) or {}
end)

Players.PlayerRemoving:Connect(function(plr)
DS:SetAsync(plr.UserId, PGP[plr.UserId])
PGP[plr.UserId] = nil
end)
1 Like

Thank you, but how can I make it save the actual true/false statements on the Boolvalue?

1 Like

I dont believe you can, you might be able to do this:

game.ReplicatedStorage.Event.OnServerEvent:Connect(function(plr, GamepassId)
if not table.find(PGP[plr.UserId], GamepassId) then
-- if the Player doesnt own the Item
table.insert(PGP[plr.UserId], GamepassId)
else
-- If the Player already owns the item and is inside the table
end
end)

Call it:
LocalScript:

game.ReplicatedStorage.Event:FireServer("Your Gamepass Id")
1 Like

Here, let’s do a stringvalue instead. I know you can save stringvalues.
Also these wont be gamepasses, they’ll be ingame things you can buy with ingame cash

1 Like

should work the same way

303030303030

1 Like

This is going to take such a long time to figure everything out. I have no idea on what I’m doing but ig I’ll try.

1 Like

Watch this Video, may help with saving stuff:

1 Like

It’s really bad to do it like that, exploiter can put any gamepass id in there, like if he has other gamepass that gives another benefits but it will trigger since player has it. It’s better to have id variable on the server instead of client and then check if the player has it

1 Like