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!
What is the issue? Include screenshots / videos if possible!
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
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!
-- This is an example Lua code block
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.
this is my professional stats can someone help me to save it or DataStoreService
Stats Script:
game.Players.PlayerAdded:Connect(function(plr)
for i,v in pairs(script:GetChildren()) do
local StatsClone = v:Clone()
StatsClone.Parent = plr
end
end)
well we cant make scripts for you so the best option is to try your hardest to make a datasaving script and then show it to us if it doesnt work. please read the guidelines next time pal
If you decide to use the DatastoreService i can give some advice:
When saving data remember, lua is case sensitive so you need to use: :setAsync() not :SetAsync(), same goes for getting the data, use: :getAsync() not :GetAsync(), also always save the data on the Players UserId and always wrap setAsync and getAsync into a pcall function.
Example script:
local DatastoreName = "" --The name of your datastore goes into the ""
local MyDatastore = game:GetService("DataStoreService"):GetDataStore(DatastoreName)
local DatastoreKey = "~Key~._" --Always save the data with a key (Replace the word " key " regarding on your data topic)
local MyData = "" --Remove the "" and put your data into there
game.Players.PlayerRemoving:Connect(function(Player)
local data
local Success,ErrorMessage = pcall(function()
data = MyDatastore:setAsync(DatastoreKey..Player.UserId,MyData)
end)
if Success then
warn("Data has been successfully saved")
else
warn("Something went wrong while saving the data for: "..Player.Name.."\nError: "..ErrorMessage)
end
end)
game.Players.PlayerAdded:Connect(function(Player)
local data
local Success,ErrorMessage = pcall(function()
data = MyDatastore:getAsync(DatastoreKey..Player.UserId)
end)
if Success then
warn("Data has been received")
else
warn("Something went wrong while getting the data for: "..Player.Name.."\nError: "..ErrorMessage)
Player:Kick("Something went wrong while getting your data")
end
end)
If you experience issues while saving data inside studio do this: Add a BindToClose function which will save the data when the game gets closed or Try it out in the actual game