Increase Size
Prerequisites: Before you dive in!
1. Intro
2. Setup
3. Creating a Gamepass
Objective ð§ðŋâ
We are going to create a script that allows players to purchase a size increase for their character in Roblox using a Developer Product.
Description ððŠķâ
Here's what we want to accomplish:
1. Purchase Size Increase:
Players can buy a size increase for their character using a Developer Product.
2. Increase Character Size:
When purchased, the character's size will increase temporarily.
3. Restore Original Size:
After a short duration, the character's size will return to normal.
By doing this, we will create a dynamic gameplay feature where players can temporarily grow their character's size through in-game purchases.
Instructions and Code Logic ððâ
Step 1 - Get the Necessary Servicesâ
-
Get the
MarketplaceService
from the game. -
Get the
Players
service from the game.
Step 2 - Set Up Developer Product IDâ
- Define the Developer Product ID for the size increase purchase (
DEV_PRODUCT_SIZE_INCREASE
).
Step 3 - Create a Function to Handle Size Increaseâ
-
Define a function named
grantSizeIncrease
that takes aplayer
as an argument. -
Inside the function, get the player's character.
-
Store the original scales of the character's body parts.
-
Increase the scales of the body parts to double their original size.
-
Wait for 5 seconds (the duration of the size increase).
-
Reset the scales of the body parts to their original sizes.
Step 4 - Create a Function to Process Receiptsâ
-
Define a function named
processReceipt
that takesreceiptInfo
as an argument. -
Inside the function, get the player from the receipt information.
-
If the player is not found, return
Enum.ProductPurchaseDecision.NotProcessedYet
. -
Use a
pcall
to handle any errors during processing. -
If the
ProductId
matches the size increase product, call thegrantSizeIncrease
function for the player. -
Return
Enum.ProductPurchaseDecision.PurchaseGranted
if successful, otherwise returnEnum.ProductPurchaseDecision.NotProcessedYet
.
Step 5 - Set the Callback Functionâ
- Set
MarketplaceService.ProcessReceipt
to theprocessReceipt
function to handle purchase processing.
Putting It All Together ð§ðĐâ
-
Start by getting the necessary services and setting up the Developer Product ID.
-
Define functions to handle size increase and receipt processing.
-
Set the callback function for processing receipts.
By following these simple steps, you can create a script that allows players to purchase a size increase for their character, with the size returning to normal after a short duration.