How do i change a players character if they own a gamepass?

Im not sure how to change a players character if they own a gamepass, can someone help?

To detect if a user has a gamepass you can use the MarketPlaceService

local MarketPlaceService = game:GetService("MarketPlaceService")

if MarketPlaceService:UserOwnsGamePassAsync(player_User_Id, Gamepass_Id) then
    --Change character here
end
1 Like

i know how to use marketplaceservice, im just not sure how to change the players character

Could you be more specific when you say “change the players character”? Do you mean change their character model or just add a accessory or something?

changing their character model

give an example please so we can help

i have a character model in workspace and if they have the gamepass i want that character model to be their character

 thePlayer.Character = Model-- try this

note: make sure the model is rigged properly

1 Like
local MarketPlaceService = game:GetService("MarketplaceService")


game.Players.PlayerAdded:Connect(function(plr)

	plr.CharacterAdded:Connect(function()

		
		if MarketPlaceService:UserOwnsGamePassAsync(Player_Id, Gamepass_ID) then
		   	local CharacterClone = game.ReplicatedStorage.Characters:FindFirstChild("Insert The name of your character here"):Clone()
			CharacterClone .Name = plr.Name
			plr.Character:Destroy()
			plr.Character = CharacterClone
			CharacterClone .Parent = game.Workspace
		end
	
	end)

end)

This should work, You just need to have a folder in replicated storage named Characters and put your character in that folder, then you need to change :

"Insert The name of your character here"

To the name of that character model

1 Like
 CharacterClone.Parent = game.Workspace -- you gave a space
1 Like

attempt to index nil with ‘Destroy’

local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassId = 16558561
game.Players.PlayerAdded:Connect(function(player)
if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassId) then
		local CharacterClone = game.ReplicatedStorage:FindFirstChild("LightningMan"):Clone()
		CharacterClone.Name = player.Name
			player.Character:Destroy()
			player.Character = CharacterClone
			CharacterClone.Parent = game.Workspace
	end
end)

I think you need to add this

plr.CharacterAdded:Connect(function()

end)

Because when the player joins the game there character isn’t loaded yet.
This line waits for the character to be added

local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassId = 16558561
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassId) then
				local CharacterClone = game.ReplicatedStorage:FindFirstChild("LightningMan"):Clone()
				CharacterClone.Name = player.Name
					player.Character:Destroy()
					player.Character = CharacterClone
					CharacterClone.Parent = game.Workspace
			
		end
	end)
end)

how about you change the order

local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassId = 16558561
game.Players.PlayerAdded:Connect(function(player)
if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassId) then
 	local CharacterClone = game.ReplicatedStorage:FindFirstChild("LightningMan"):Clone()
 	CharacterClone.Name = player.Name
 		player.Character = CharacterClone
                     player.Character:Destroy()
 		CharacterClone.Parent = game.Workspace
 end
end)

now it says The Parent property of NotZylon is locked, current parent: NULL, new parent Workspace

That didn’t work either

Hmm try this

local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassId = 16558561
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Wait(function()
		if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassId) then
				local CharacterClone = game.ReplicatedStorage:FindFirstChild("LightningMan"):Clone()
				CharacterClone.Name = player.Name
					player.Character:Destroy()
					player.Character = CharacterClone
					CharacterClone.Parent = game.Workspace
			
		end
	end)
end)

nope still doesn’t work

Hmm what error is it giving?
Cause I can’t see where it’s broken

it’s giving no error at all

and what is the line its errroring???