What is a datastore and how do i use it and is it needed for a game? Please help!
A datastore is what you use to save things. Example; Say I want to save levels in a game I'd first create a folder and parent it to something. Then I'd create an instance.new of a intvalue for the level and put it inside the folder. Here's an example that would load on join and save on leave.
local player = game:GetService("Players") local SS = game:GetService("ReplicatedStorage") local DS = game:GetService("DataStoreService") -- Creating the local Data makes a new table for the data to go into local data = { ["Level"] = DS: GetDataStore("Level") } player.PlayerAdded:connect(function(plr) -- Function to see a player join local success, err = pcall (function() -- pcall to secure the data local userID = plr.userId local stats = Instance.new("Folder") stats.Name = "Stats" stats.Parent = plr -- Creates new Folder and makes it go into the player local Level = Instance.new("IntValue") Level.Name = "Level" Level.Parent = stats -- Creates the IntValue Level and puts it in stats Level.Value = data["Level"]:GetAsync(userID) or "1" -- Syncs the user's Level to saved stat or if none sets it to 1 end) if success then print ("Success") -- Successful pcall end end) player.PlayerRemoving:connect(function(plr) local userID = plr.userId local stats = plr:WaitForChild("Stats") -- get the stat folder data["Level"]:SetAsync(userID, stats.Level.Value) -- Syncs the player's current level to the Level table, causing it to save. end)
Hoped this made sense or helped, I'm kind of new to scripting too