Potion System Help

I have been thinking of creating a potion system in my game, which grants 5 minutes of jumpboost to the player if they buy a dev product. How would I go about this? Also, when the player buys the jumpboost and the timer starts going down, would it be wise to use a while loop or a run service connection?

1 Like

Hook a callback to MarketplaceService.ProcessReciept which checks if the devproduct id and increases players JumpPower to a high value and run a task.delay(300) after which you reset the JumpPower

2 Likes

Thanks. What if the player logs off though. Wouldn’t the task delay be reset?

1 Like

No, but you could make a dictionary which stores all jump power threads and listen for PlayerRemoved and call task.cancel(jumpThreads[player]). To do that, you need to do this when processing purchase:

if jumpThreads[player] and corutine.status(jumpThreads[player]) ~= "dead" then
   task.cancel(jumpThreads[player])
end

jumpThreads[player] = task.delay(300, function()
    player.Character.Humanoid.JumpPower = DEFAULT
end)
1 Like

So I should use PlayerAdded to create jump threads for each player or should I only create jump threads when they buy the dev product?

Ye

Thanks for the idea. I’m not very familiar with coroutines and tasks so I will look into it.