Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

DataSaving Inventory using BoolValues possible?

Would it be possible to data save bool/string/int values using DataStore? Here is my script, its for one item but I plan to have a lot:

LocalScript inside button in StarterGUI:

local button = script.Parent
local player = game.Players.LocalPlayer

button.MouseButton1Down:Connect(function(input)
	if player.leaderstats.Credits.Value >= 50  then
			player.Character.Humanoid.WalkSpeed = 60
		game.ReplicatedStorage.ShopEvents.RemoveFifty:FireServer()
	end
end)

ServerScript inside ServerScriptService:

local value = game.ReplicatedStorage.ShopValues.FirstWalkspeed

game.ReplicatedStorage.ShopEvents.RemoveFifty.OnServerEvent:Connect(function(player)
	
	player.leaderstats.Credits.Value = player.leaderstats.Credits.Value - 50
	value.Value = true
end)

The BoolValue is inside ReplicatedStorage, thanks!

2 comments

0

This is related to the question but check if the player's credits are greater than 50 on the server, since that's easily exploitable.

0

Got it, thanks

1 answer

You can save the BoolValue.

DataStore:SetAsync(player.UserId, value.Value)

Edit: If you want to save multiple, put it into a table.

local data = {true, 50, 2.5}  -- I'm pretty sure that the limit is 30 requests.

DataStore:SetAsync(player.UserId, data)

2 comments

0

would i be able to do multiple?

0

Sure. I'll edit this for you so you can see how to save multiple.

This discussion is preserved as it was. New answers, comments, and votes are closed.