Trying to save humanoid properties failing

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    for the humanoid property to be saved to the player
  2. What is the issue? Include screenshots / videos if possible!
    when i load into the game the speed is reset to the default speed
    and it dosen’t want to load nor save
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i have looking into the issue before but had not luck i looked on the Hub and couldn’t find an answer

Do you want to save properties on leave and load them on join?

Yeah like if it’s changed to let’s say 64, when they leave it saves, so when the re join it has the value

My solution would be to make a leaderstats of the speed of each player and the value as there speed so you can constantly update the value to the current speed then just watch this video of datastores:

(Please reply to me instead of yourself so I can get a notification)

To do this you need to use DataStoreService. Create a script in ServerScriptService.

local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")

local SpeedDataStore = DataStoreService:GetDataStore("SpeedDataStore")

Players.PlayerAdded:Connect(function(player)
   local SpeedValue = Instance.new("NumberValue")
   SpeedValue.Name = "SpeedValue"
   SpeedValue.Parent = player

   local Character = player.Character or player.CharacterAdded:Wait()
   local Humanoid = Character:FindFirstChildOfClass("Humanoid")

   if not Humanoid then repeat Character.ChildAdded:Wait() until Character:FindFirstChildOfClass("Humanoid")
   
   local Speed = SpeedDataStore:GetAsync(player.UserId) or 16
   Humanoid.WalkSpeed = Speed
   Player.CharacterAdded:Connect(function(char)
      char.Humanoid.WalkSpeed = Speed
   end) 
  
 
 Humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
      SpeedValue.Value = Humanoid.WalkSpeed
   end)

Players.PlayerRemoving:Connect(function(player)
   local SpeedValue = player:FindFirstChild("SpeedValue")
   if not SpeedValue then return end
   SpeedDataStore:SetAsync(player.UserId, SpeedValue.Value)
end)

i gave it a try and it dosen’t want to save it

Is there any errors in the output?

you might have to test in-game because datastores doesn’t work in studio sometimes

Yes, I forgot about it. He either has Studio access to API services disabled, either the problem is that he needs to add a game:BindToClose() function.

Yeah on my other I use bindtoclose to save, but should I add it to the script?

Try testing this in the Roblox Player at first to see if its working.

Please reply to me, so I will always know that you replied.(click arrow under my post)

nah when i tried it with bindtosave it didn’t save nor show it

Show your code please. 30 chaars

local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")

local SpeedDataStore = DataStoreService:GetDataStore("SpeedDataStore")

Players.PlayerAdded:Connect(function(player)
	local SpeedValue = Instance.new("NumberValue")
	SpeedValue.Name = "SpeedValue"
	SpeedValue.Parent = player

	local Character = player.Character or player.CharacterAdded:Wait()
	local Humanoid = Character:FindFirstChildOfClass("Humanoid")

	if not Humanoid then repeat Character.ChildAdded:Wait() until Character:FindFirstChildOfClass("Humanoid")

		local Speed = SpeedDataStore:GetAsync(player.UserId) or 16
		Humanoid.WalkSpeed = Speed
		Players.CharacterAdded:Connect(function(char)
			char.Humanoid.WalkSpeed = Speed
		end) 


		Humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
			SpeedValue.Value = Humanoid.WalkSpeed
			
		end)
		
Players.PlayerRemoving:Connect(function(player)
	local SpeedValue = player:FindFirstChild("SpeedValue")
		if not SpeedValue then return end
			SpeedDataStore:SetAsync(player.UserId, SpeedValue.Value)
		end)
	end
end)

game:BindToClose(function()
	wait(3)
end)

game:BindToClose should not just be a wait. It needs to save data for players itself using for loops looking for players.

Thats not how it working. You need to save every player’s data on close. Like this:

game:BindToClose(function()
   for _, player in ipairs(Players:GetPlayers()) do
      SpeedDataStore:SetAsync(player.UserId, player.SpeedValue.Value)
   end
end)

yeah even with that the value still shows 0

Please try this in Roblox Player, not Roblox Studio.

Yeah I’ve tried on bother studio and the player