Hello everyone I have a leaderboard cash saving script that works perfect. But I don't know how I can save the cars when they're purchased. I have the car purchase scripted so I don't need help with that. If you guys can send links or ideas. A push in the right direction is all I need.
Hi week,
Thanks,
Best regards,
~~ KingLoneCat
So this is sort of tricky, considering Datastores are mainly used for Leaderstats. What you can do, is set a BoolValue inside of the car, and when the player buys it, set the bool value to True. Then make a datastore FOR the boolvalue, and finally make a script that checks when a player joins if the Bool is set to true, and if it is, then give the player the car. So just add a bool into the car, in the car giving script add a line that sets the bool to true when bought, add a datastore for the bool (Made one for you, look below) and make a script that checks if a player has bool when they join the game. (Also made one for you)
Put both these inside ServerScript's in ServerScriptService
Bool-Datastore script:
local datastore = game:GetService("DataStoreService") local ds1 = datastore:GetDataStore("CoinSaveSystem") game.Players.PlayerAdded:Connect(function(plr) local Bool = --Set this variable to wherever the BoolValue is located Bool.Value = ds1:GetAsync(plr.UserId) or false ds1:SetAsync(plr.UserId, Bool.Value) Bool.Changed:Connect(function() ds2:SetAsync(plr.UserId, Bool.Value) end) end)
CarChecker script:
game.Players.PlayerAdded:Connect(function(player) local Bool = --Set to location of Bool if Bool.Value == true then --Add Code Here to Give the Players the car else print("Player didn't already own car") end end)
Feel Free to report any errors or questions