When a player joins they have their user id folder stored in replicatedstorage. For accessing stuff etc.
You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
The cars and the currentcar is saved and I want to save every numbervalue inside of the folder. -
What is the issue? Include screenshots / videos if possible!
The issue is that it is missing these values and these are not storing: RealCoins, Exp, MaxExp, Level -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I didn’t want to try anything so as to not break the script.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Tables = game:GetService('DataStoreService'):GetDataStore('Tables V.07')
local Car = game:GetService('DataStoreService'):GetDataStore('CurrentCar V.07')
local BasicData = game:GetService('DataStoreService'):GetDataStore('BasicData V.06')
--< Functions >--
function GetDescendant(o,n)
local Object = nil
for Index,Value in pairs(o:GetDescendants()) do
if (Value).Name == n then
Object = Value
break
end
end
return Object
end
local function Create(Properties,Parent,Class)
local Object = Instance.new(Class)
for Property, Value in next, (Properties) do
Object[Property] = Value
end
Object.Parent = Parent
return Object
end
local function OnPlayerAdded(Player)
local Playing = Create({
['Name'] = 'Playing';
},Player,'BoolValue')
print(Playing.Parent)
local TEntry = Tables:GetAsync(Player.UserId) or {}
local CEntry = Car:GetAsync(Player.UserId)
local AEntry = BasicData:GetAsync(Player.UserId)
local Folder = ReplicatedStorage:WaitForChild(Player.UserId)
local OwnedCars = Create({
['Name'] = 'OwnedCars';
},Folder,'Folder')
for _,Entry in pairs(TEntry) do
local Car = GetDescendant(game.ReplicatedStorage.TheGarageShop,Entry)
if (Car) then
Car:Clone().Parent = OwnedCars
end
end
if (CEntry) ~= nil then --?
local Object = Create({
['Name'] = 'CurrentCar'
},Folder,'ObjectValue')
local CurrentCar = GetDescendant(game.ReplicatedStorage.TheGarageShop, CEntry)
Object.Value = CurrentCar
Playing.Value = true
Player.CharacterAdded:Connect(function(Character)
Player.Character.HumanoidRootPart.Anchored = false
end)
else
local gui = script.ScreenGui:Clone()
gui.Play.TextButton.LocalScript.Disabled = false
gui.Parent = Player.PlayerGui -- change made here so the screen gui can show up
Player.CharacterAdded:Connect(function(Character)
Player.Character.HumanoidRootPart.Anchored = false
end)
end
end
local function OnPlayerRemoving(Player)
local Table = ReplicatedStorage[Player.UserId].OwnedCars:GetChildren()
local Data = {}
if ReplicatedStorage[Player.UserId]:FindFirstChild('CurrentCar') then
if ReplicatedStorage[Player.UserId].CurrentCar.Value ~= nil then
Car:SetAsync(Player.UserId, ReplicatedStorage[Player.UserId].CurrentCar.Value.Name)
end
end
for _,Object in pairs(Table) do
table.insert(Data,Object.Name)
end
Tables:SetAsync(Player.UserId,Data)
end
--< Main - Program >--
game:GetService('Players').PlayerAdded:Connect(OnPlayerAdded)
game:GetService('Players').PlayerRemoving:Connect(OnPlayerRemoving)
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.