Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
vxnnisu 17
3 years ago
Edited 3 years ago

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!

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. radiant_Light203 1166 — 3y
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. radiant_Light203 1166 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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..

0
Thanks. Could I get a recode? I'm new to scripting and I'm not 100% sure how to do that. vxnnisu 17 — 3y
0
Yeah jorcorrs 76 — 3y
Ad

Answer this question