How to save player walkspeed

another error :
image

1 Like

change the HeartBeat to “Heartbeat”

1 Like

sorry i scripted this in here so im kinda dum

1 Like

like this?

1 Like

noooooo ok…
game[“Run Service”].Heartbeat:Connect(function()
local plr = game.Players:GetPlayerFromCharacter(script.Parent)
if plr then
if plr.walkspeed then
plr.walkspeed.Value = script.Parent:FindFirstChild(“Humanoid”).WalkSpeed
end
end
end)

1 Like

It doesnt give a error now but where does it store the walkspeed?

1 Like

just wait and ill just write the serverscript aswell in roblox studio

1 Like

ok, thank you for youre help! :grinning:

1 Like

Np…
local dataStore = game:GetService(“DataStoreService”):GetDataStore(“TestVersion1”)
local speedData = game:GetService(“DataStoreService”):GetDataStore(“whateveruwanthere”)
game.Players.PlayerAdded:Connect(function(plr)
wait()
local plrid = “id_”…plr.UserId
local save1 = plr.leaderstats.Stage
local save2 = plr.leaderstats.Wins
local data
local new = Instance.new(“IntValue”,plr)
new.Name = “walkspeed”
pcall(function()
data = speedData:GetAsync(plr.UserId)
end)
if data ~= nil then
new.Value = data
end
local GetSaved = dataStore:GetAsync(plrid)
if GetSaved then
save1.Value = GetSaved[1]
save2.Value = GetSaved[2]
else
local NumberForSaving = {save1.Value,save2.Value}
dataStore:GetAsync(plrid,NumberForSaving)
end
end)

game.Players.PlayerRemoving:Connect(function(plr)
dataStore:SetAsync(“id_”…plr.UserId, {plr.leaderstats.Stage.Value,plr.leaderstats.Wins.Value})
speedData:SetAsync(plr.UserId,plr.walkspeed.Value)
print(“Saved data”)
end)

this is the server script
replace it with this

and this is the startercharscript
game[“Run Service”].Heartbeat:Connect(function()
local plr = game.Players:GetPlayerFromCharacter(script.Parent)
if plr then
if plr.walkspeed then
script.Parent:FindFirstChild(“Humanoid”).WalkSpeed = plr.walkspeed.Value
plr.walkspeed.Value = script.Parent:FindFirstChild(“Humanoid”).WalkSpeed
end
end
end)

2 Likes

but now the problem is that the player starts with 0 walkspeed, is there a way to fix this?

my bad for late reply…
reasons its not working:
walkspeed data didnt load
its not applying correctly

2 Likes

The script is working perfectly fine! Its just that if the player joins first his walkspeed is at 0 so that means you cant walk, is there a way to fix this? Also sorry for my late reply!

My bad,

i did something wrong, its working now. Thank you so much for you’re help!

1 Like

no problem!!!..

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.