Hello everyone, it’s me InquistorWasBanned. First of all, I do not know which category this problem should go into, but I currently have a Starter Character that looks like a regular basic noob, and I want to make a game pass that if someone buys, they can change back to their original Roblox character. How would I be able to do this? People always talk about StarterCharacters but they never talk about this.
How about this:
Instead of startercharacter, you give them body parts/clothes/all that on join through a script?
However, it checks for the gamepass and if it finds it, then it doesn’t change the character.
EDIT: Grammar mistake
Put this is a server script in ServerScriptService:
local MPS = game:GetService("MarketplaceService")
local PassID = 0000000 -- Put ID here
game.Players.PlayerAdded:Connect(function(player)
if MPS:UserOwnsGamePassAsync(player.UserId, PassID) == false then
-- put stuff here to change character
end
end)
Hm Okay but the problem is can I use other people’s products or can it only be mine? Because I got an idea. What if I add like an if then statement in my starter character? I can do like if the player has (Gamepass) then it would return false to make the starter character. I could make like a variable set to true before on the top. How do you think?
Tbh, I don’t have much experience with StarterCharacter (I never use it) so I wouldn’t know about that.
Okay Thanks for trying to help me!
if anyone else can help if you know how Please help! Thanks!
I would suggest moving this topic to #help-and-feedback:scripting-support
And to answer your question…
That’s perfectly fine too. I would recommend @R0bl0x10501050 's method:
…because to me it seems a little more effective and neater, but you do you.
What R0bl0x said in the first post. Change your approach.
StarterCharacter isn’t intended for this purpose: it’s meant to be a static, unchanging way of building the character rig. If you want to be changing the appearance of a user and nothing else, then you should be using other options such as HumanoidDescriptions or working with actual character clothing objects.
If you do it that proper way, then you can simply make it so that anyone without the game pass gets changed into the default noob character. So in that regard rather than “undoing” the appearance change, you’re instead keeping their appearance unchanged if they have the game pass.
If you want to use the HumanoidDescription method, then set one up so that the appearance upon being applied makes a character turn into a noob. Put that somewhere: for my code sample I’ll pretend you put it directly in ServerStorage. Next steps are very straight forward.
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local DEFAULT_APPEARANCE = ServerStorage.DefaultAppearance
local GAME_PASS_ID = 0
local function applyDefaultAppearance(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid:ApplyDescription(DEFAULT_APPEARANCE)
end
local function playerAdded(player)
local success, canBypassDefaultAppearance = pcall(function ()
return MarketplaceService:UserOwnsGamePassAsync(player.UserId, GAME_PASS_ID)
end)
-- If we can't get the pass ownership or if they don't own it, use default appearance
if (success and not canBypassDefaultAppearance) or not success then
player.CharacterAppearanceLoaded:Connect(applyDefaultAppearance)
if player:HasAppearanceLoaded() then
applyDefaultAppearance(player.Character)
end
end
end
Players.PlayerAdded:Connect(playerAdded)
for _, player in ipairs(Players:GetPlayers()) do
playerAdded(player)
end
I would do this to change their character from the startercharacter:
local MarketPlace = game:GetService("MarketPlaceService")
local GamePass = 0000
game.Players.PlayerAdded:Connect(function(player)
local owns = false
if MarketPlace:UserOwnsGamePassAsync(player.UserId, GamePass) then
owns = true
end
player.CharacterAdded:Connect(function(char)
if owns then
local description = game.Players:GetHumanoidDescriptionFromUserId(player.UserId)
char.Humanoid:ApplyDescription(description)
end
end)
end)
Would I put this in ServerScriptService?, and on the first line there is an error showing for MarketPlaceService because it is not defined.
Nope, not what I said. StarterCharacter isn’t used for the purpose of changing the way a character looks. The spirit of using StarterCharacter is to change the way a rig is built (e.g. using new limbs and having that apply to all characters). What I said was to work with the HumanoidDescription system. Please read the post thoroughly, as it includes the information you need.