so ive looked at this for like 20 mins and gave up in the output theres no errors so yeah heres my script:
local datastoreservice = game:GetService("DataStoreService")
local StatsData = datastoreservice:GetDataStore("StatsData")
game.Players.PlayerAdded:Connect(function(player)
local playerId = "Player_"..player.UserId
local Stats = Instance.new("Folder")
Stats.Name = "Stats"
Stats.Parent = player
local Money = Instance.new("IntValue")
Money.Name = "Money"
Money.Parent = Stats
local Stamina = Instance.new("IntValue")
Stamina.Name = "Stamina"
Stamina.Parent = Stats
local data
local success, errormsg = pcall(function()
data = StatsData:GetAsync(playerId)
end)
if success then
if data then
Money.Value = data.Money
Stamina.Value = data.Stamina
end
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local playerId = "Player_"..player.UserId
local success, errormsg = pcall(function()
local data = {
Money = player.Stats.Money.Value;
Stamina = player.Stats.Stamina.Value;
}
StatsData:SetAsync(playerId, data)
end)
if success then
print("Data Saved")
else
print("Failed to save Data")
warn(errormsg)
end
end)
the api is turned on this is wat i get in the output
18:44:07.683 Infinite yield possible on 'ServerScriptService:WaitForChild("Humanoid")' - Studio
18:44:07.683 Stack Begin - Studio
18:44:07.684 Script 'ServerScriptService.PlayerProperties', Line 5 - Studio - PlayerProperties:5
18:44:07.684 Stack End - Studio
18:44:12.767 Infinite yield possible on 'Workspace.Roastdbacon.Animate:WaitForChild("PlayEmote")' - Studio
18:44:12.767 Stack Begin - Studio
18:44:12.767 Script 'Workspace.Roastdbacon.Animate', Line 729 - Studio
18:44:12.767 Stack End - Studio
18:44:12.767 Infinite yield possible on 'Players.Roastdbacon:WaitForChild("stats")' - Studio
18:44:12.767 Stack Begin - Studio
18:44:12.767 Script 'Players.Roastdbacon.PlayerGui.PlayersHud.Stamina.Meter.LocalScript', Line 7 - Studio
18:44:12.767 Stack End - Studio
18:44:13.210 Disconnect from ::ffff:127.0.0.1|50846 - Studio
local frame = script.Parent
local character = game:GetService("Players").LocalPlayer.character
local human = character:WaitForChild("Humanoid")
local player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local stats = player:WaitForChild("stats")
local Stamina = stats:WaitForChild("Stamina")
local sprinting = false
human.Running:Connect(function(speed)
if speed >= 19 then
sprinting = true
end
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftControl then
if sprinting == true then
print(Stamina.Value)
end
end
end)
Your datastore script looks fine. Check your scripts that change the values. They might not be working and the values never change so you think the datastore script doesn’t work.
Ok that’s the problem. If you’re changing the value in the explorer on the client side, the server doesn’t know the value changed because of FilteringEnabled. Click Test and change to the Server. Then when you change it in the explorer, it can be saved.