So I am new to scripting and almost done with my first game. I am working on a gamepass that when a players buys it their walkspeed changes to 32. Here is what I have so far
local id = 15211319
game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
if purchased and id == ido then
plr.Character.Humanoid.WalkSpeed = 32
end
end)
game.Players.PlayerAdded:Connect(function(plr)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId,id) then
game.Workspace:WaitForChild(plr.Name):WaitForChild("Humanoid").WalkSpeed = 32
end
end)
The issue I am having is that once a player dies it resets their walkspeed back to 16. After they die I want it to stay at 32.