So I made a script saying if you have one coin, walkspeed is = 21
local players = game.Players.LocalPlayer script.Parent.MouseButton1Click:Connect(function(Click) if players.leaderstats.Coins.Value >= 1 then players.leaderstats.Coins.Value = players.leaderstats.Coins.Value - 1 players.Character.Humanoid.WalkSpeed = 21 end end)
But it came to my attention that when you die, your walkspeed get reset. can you help me? (Keep in mind that I have more than one of these scripts, and each one costs more and makes you faster.)
You could save the value of the walkspeed somewhere other than the script and have another script load the walkspeed. You could also go to extremes and use datastores to save their data even when they leave the game (Save the walkspeed value in the player, not the character).
Btw, even with the new improvements, this script wouldn't work because player.Character doesn't work in localscripts. Or, if this isn't a localscript, Game.Players.LocalPlayer only works in localscripts. I Hope this helps!
game.Players.PlayerAdded:Connect(function(player) player.CharacterAddded:Connect(function(character) script.Parent.MouseButton1Click:Connect(function() if player.leaderstats.Coins.Value >= 1 then player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - 1 walkspeedbeforedeath = 21 character.Humanoid.WalkSpeed = walkspeed end end) end) end) game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:WaitForChild("Humanoid"):Connect(function(character) character.Humanoid.WalkSpeed = walkspeedbeforedeath end) end)
again, idk if this works, but it's pretty much what I can help. If it doesn't work, please be more specific as you can and try searching it on google.