I’m asking for help on how to do the step counter because
- I’m new to coding and dont know much
- I cannot find anything about this topic on youtube or here
Heres my leaderstat code thats being buggy and kicking me i cannot figure out the problem
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("DataStore")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local Money = Instance.new("IntValue")
Money.Name = "Money"
Money.Parent = leaderstats
local Steps = Instance.new("IntValue")
Steps.Name = "Steps"
Steps.Parent = leaderstats
local Stage = Instance.new("IntValue")
Stage.Name = "Stage"
Stage.Parent = leaderstats
local data
local success, message = pcall(function()
data = DataStore:GetAsync(plr.UserId .. "-Data")
end)
if success then
if data then
Money.Value = data
end
else
warn(message)
plr:Kick("Error while retrieving your data.")
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local data = plr.leaderstats["Money"].Value
local success, message = pcall(function()
DataStore:SetAsync(plr.UserId .. "-Data", data)
end)
if not success then
warn(message)
end
end)
this is a screenshot of the problem (leaderstats)