Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I replace a StarterCharacter with a different StarterCharacter if a gamepass is purchased?

I'm trying to make a chair simulator game where you are a chair, and if you buy a gamepass, it will turn only you into a table. I'm finding some trouble getting the chair turned into a table. I have put a folder with the StarterCharacter of the table in ReplicatedStorage, and I put a script in ServerScriptService that has the following line of code in it:

local starterplayer = game.StarterPlayer
local Avatar = game:GetService("ReplicatedStorage"):FindFirstChild("Table").StarterCharacter


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

	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 20094414) then
		local PlayerAvatar = Avatar:Clone()
		game:GetService("StarterPlayer").StarterCharacter:Destroy()
		PlayerAvatar.Name = "StarterCharacter"
		PlayerAvatar.Parent = game:GetService("StarterPlayer")
		wait(0.1)
		player:LoadCharacter() 
	end
end)

I would note also that the GUI button that gives you the gamepass is fine, it's this script is the problem. If I'm wrong, please tell me. Also, there is already a StarterCharacter model in StarterPlayer. This is why I have it destroyed when you get the gamepass, so that you aren't a chair, you are a table. I would extremely appreciate it if this was solved. Thank you!

2 comments

0

You can't set the starter character differently for different players. Instead, clone the table, set the player's character to the clone (player.Character = table) and set the table's parent to the workspace. Make sure to do this whenever the player spawns.

0

There might be a few other things you'll need to do manually, which are otherwise done by :LoadCharacter(), such as cloning character scripts.

1 answer

The player has an object value inside of it called "Character" which you could change without having to respawn the player, you would just have to add a character added event and change the player's character through there..

2 comments

0

Thanks. Could I get a recode? I'm new to scripting and I'm not 100% sure how to do that.

0

Yeah

This discussion is preserved as it was. New answers, comments, and votes are closed.