Game Pass Owner Morph On Touch

Hey there!
How do I make a script that detects when a player touches a rig, and if they own a certain game pass, it morphs them into that rig?

Simply by using MarketplaceService, especially MarketplaceService:UserOwnsGamePassAsync().

The script architecture should consist of a single Touched event on any BasePart, preferably a single invisible hitbox. A debounce should be in place to avoid spamming the API. Finally, you have to find the player from the touched part, which is done by using Players service.

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local TouchPart -- set the desired part with the functionality

local GAME_PASS_ID -- ID of gamepass

local debounce -- no assignment needed

TouchPart.Touched:Connect(function(touched)
	if debounce then
		return
	end
	debounce = true
	
	local character = touched:FindFirstAncestorOfClass("Model")
	local player = Players:GetPlayerFromCharacter(character)
	if player then
		if Marketplace:UserOwnsGamePassAsync(player.UserId, GAME_PASS_ID) then
			-- morph code, this is completely subjective to the rig
		end
	end
	
	wait(5) -- cooldown, basic but could be substituted if time should be precise
	debounce = false
end)

The morphing depends on what kind of character rig it is and the method that should be employed on such rigs. However, that functionality is subjective to your preference.

1 Like