Still have questions? Join our Discord server and get real time help.
0

# how would i save a variable?

ok so, each time a player joins my game, they pick a class which I want to keep the same until they leave. I tried doing this by having a StringValue inside the starter character and setting that to whatever they choose, but then every time they die this value is reset and that's not what I want to happen lol. how would ya'll suggest doing this because I don't really know where to start?

0

I would add the value it serverstorage

local folder=Instance.new("Folder",game.ServerStorage) --making a folder in serverstorage
folder.Name="stuff"  --name the folder
local stat=Instance.new("StringValue",folder)
stat.Name=player.Name --sets the name of the string value to the players name
end)

--remove value when player leaves
game.Players.PlayerRemoving:Connect(function(player)
local stat=folder:FindFirstChild(player)
--if player has stats then
if stat then
stat:Destroy()
end
end)



to find a players stat

local folder=game.ServerStorage:WaitForChild("foldername") --change name of folder to the name of the folder
local stat=folder:FindFirstChild(player)
if stat then
--has stats
else
--no stats
end


hope this helps

0
ohh i get it, thank you! snaplegs 1 — 2mo
0
pls tab your code correctly kingdom5 5294 — 2mo