I made a gmae where you can buy speed for cash. You can buy speed, but if you die, your speed is set to 0. Also, if you leave, you walkspeed is reset. Here is my level 1 speed script:
local players = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function(Click)
if players.leaderstats.Cash.Value >= 1 then
players.leaderstats.Cash.Value -= 1
players.Character.Humanoid.WalkSpeed = 21
thews = 21
end
end)
players.CharacterAdded:Connect(function(c)
c:WaitForChild("Humanoid").WalkSpeed = thews
end)
local players = game.Players.LocalPlayer
script.Parent.TouchTap:Connect(function(Click)
if players.leaderstats.Cash.Value >= 1 then
players.leaderstats.Cash.Value -= 1
players.Character.Humanoid.WalkSpeed = 21
thews = 21
end
end)
players.CharacterAdded:Connect(function(c)
c:WaitForChild("Humanoid").WalkSpeed = thews
end)
Is there something I can add that makes this permanent if they buy this? All help is appreciated!

2 comments
will that make the walkspeed permanent?
yes it would make it so that when the player joins it checks the datastore if they joined before and get the last speed save