How to make a standstorage

how to make a stand storage that save your stand and you can change it

Try to make what you want more clear, I do not understand your wording!

i was tryna to make a jojo game , and now i want to make a standstorage that u can save your stand in it and change your stand

Do you have any code already? If not then I might be able to help - im not good at datastoring.

Just use datastores to save a table that has the names of the stands they own inside of it.
Example:

local OwnedStands  = {"Bob", "Tim", "Charlotte"}

Oh, that makes sense, you would use table.Insert

i have a code which save player data and stand. will that work?

Can you show me it? I can check for errors, bugs or things you could do more smartly!

local DataStore = game:GetService(“DataStoreService”)
local GameData = DataStore:GetDataStore(“Data 1”)

game.Players.PlayerAdded:Connect(function(Player)
local PlrStats = Instance.new(“Folder”,Player)
PlayerStat.Name = “PlayerStats”

local Stand = Instance.new("StringValue",PlrStats)
Stand.Name = "Stand"
Stand.Value = ""

local saves

pcall(function()
	saves = GameData:GetAsync(Player.UserId)
end)

if saves then
	warn("Player has data")
	Stand.Value = saves
else
	warn("No Data found")
end

end)

game.Players.PlayerRemoving:Connect(function(Player)
local PlrStats = Player:WaitForChild(“PlrStats”)
saveData(Player,PlrStats)
end)

function saveData(Player,PlrStats)
local Stand = PlrStats:WaitForChild(“Stand”)

GameData:SetAsync(Player.UserId, Stand.Value)
warn("Player Data Saved!")

end

Is your problem that you can only save 1 stand?

this code have a bug. sometime it wont save the data

Well i’m not good with datastores, and I don’t see any bugs.

no i was trying to make a npc to let player save and change their stand

So you’re trying to make a game where you can save your spawn point by pressing something, kinda of like minecraft?

Use UserInputService with a keycode

yep pretty much like that how to do it?

Like @2jammers said I don’t think there are any errors in the script. A way you can make a player change their owned stand is to have whatever that changes their stand set the string value “Stand” to their new stand name.

Use a StringValue with the players current position the value could be: x/y/z
Use the HumanoidRootPart for the player position
Then connect a function with UserInputService to tell the string value to change to the root parts position on keydown for example:

local value = script.Parent.PlayerPos
local uis = game:GetService("UserInputService")

game.Players.PlayerAdded:Connect(function(player)
     player.CharacterAdded:Connect(function(char)
          uis.InputBegan:Connect(function(input)
               if input.Keycode == Enum.KeyCode.L then
                   value.Value = char.HumanoidRootPart.Position
end)
end)
end)

Not sure if this works but tell me if the value updates.

Use ContextActionService instead because it’s much better than inputservive because of it’s mobile capability. I’m confused why we are talking about this as for this is off topic. Did my solution for the stand saving work @MadionChooi ?