Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I save a walkspeed permanently?

Asked by 2 years ago

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!

1 answer

Log in to vote
0
Answered by
Puppynniko 1059 Moderation Voter
2 years ago
Edited 2 years ago

Use DataStores you can watch the tutorial or read the api https://developer.roblox.com/en-us/api-reference/class/DataStore https://www.youtube.com/watch?v=DkYupSBUpes

0
will that make the walkspeed permanent? kickoff127 103 — 2y
0
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 Puppynniko 1059 — 2y
Ad

Answer this question