1

# When player dies their speed boost ends?

Edited 5 days ago

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

0
Where is script located? Can you try putting it inside starterplayerscripts? it might work because it does not reset upon respawn Sabailuridze 126 — 5d
0
This is in ServerScriptStorage. Is it possible to put it in StarterPlayerScripts when its handling dev products? Sxribbly 16 — 4d

0
Edited 4 days ago

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

0
That's smart, cant believe I didn't think of that! It worked, thank you! Sxribbly 16 — 4d
0
No problem :) Rogue_Ram 40 — 4d