Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

When player dies their speed boost ends?

I have a dev product that temporarily gives you a speed boost. My problem is that when you die your speed goes back to normal. How can I fix this? Heres the if statement for the devproduct:

   if receiptInfo.ProductId == 1289737124 then
            print("player bought 30sec speed boost")
            player.Character.Humanoid.WalkSpeed = 40
            for i = 30, 1, -1 do -- sets 30 second timer
                gui.Text = tostring(i)
                wait(1)
            end
            player.Character.Humanoid.WalkSpeed = 16
        end

2 comments

0

Where is script located? Can you try putting it inside starterplayerscripts? it might work because it does not reset upon respawn

0

This is in ServerScriptStorage. Is it possible to put it in StarterPlayerScripts when its handling dev products?

1 answer

✓ Accepted answer

A simple way to fix this would be to update the player's walkspeed every time the loop ticks as so:

if receiptInfo.ProductId == 1289737124 then
         print("player bought 30sec speed boost")
         player.Character.Humanoid.WalkSpeed = 40
         for i = 30, 1, -1 do -- sets 30 second timer
             gui.Text = tostring(I)
		player.Character.Humanoid.WalkSpeed = 40 --Update the speed every second
             wait(1)
         end
         player.Character.Humanoid.WalkSpeed = 16
     end

So if the player dies, their speed will still be boosted within a second

2 comments

0

That's smart, cant believe I didn't think of that! It worked, thank you!

0

No problem :)

This discussion is preserved as it was. New answers, comments, and votes are closed.