So I am making a tool so that whenever you click It, It clones a random character I made Inside of a folder called "Characters" In replicastorage, then being parented Into StarterPlayer then lastly being named as "StarterCharacter", however It appears to not change Into the NPC
(Also, I was wondering how to make the disguise tool change your name when being a spesific character, like If the disguise tool changed you Into roblox your name will be changed to "Roblox" and 2 other names)
script:
local tool = script.Parent local Rep = game.ReplicatedStorage local CharacterFolder = Rep.Characters tool.Activated:Connect(function() local RandomCharacter = math.random(1,3) if RandomCharacter == 1 then local AveragePlayer = CharacterFolder["Average player"]:Clone() AveragePlayer.Parent = game.StarterPlayer AveragePlayer.Name = "StarterCharacter" end if RandomCharacter == 2 then local AveragePlayer = CharacterFolder.Girl:Clone() AveragePlayer.Parent = game.StarterPlayer AveragePlayer.Name = "StarterCharacter" end if RandomCharacter == 3 then local AveragePlayer = CharacterFolder.Troll:Clone() AveragePlayer.Parent = game.StarterPlayer AveragePlayer.Name = "StarterCharacter" end tool:Destroy() end)
Don’t put the character in the starter because the starter only works once you joined the game. Meaning you can’t change the starter player if you’re already in the game. What will you do instead is put the character in the workspace, and name it the name of the player. You can get the player by getting the character of the player using game.Players:GetPlayerFromCharacter(tool.Parent)
. After that make the player’s character ACTUALLY the character you’re trying to morph. After that you can put the character in the workspace and the script should look like this:
local tool = script.Parent local Rep = game.ReplicatedStorage local CharacterFolder = Rep.Characters tool.Activated:Connect(function() local player = game.players:GetPlayerFromCharacter(tool.Parent) local RandomCharacter = math.random(1,3) if RandomCharacter == 1 then local AveragePlayer = CharacterFolder["Average player"]:Clone() AveragePlayer.Name = player.Name player.Character = AveragePlayer local rootPart = AveragePlayer:FindFirstChild("HumanoidRootPart") or AveragePlayer:FindFirstChild("Torso") local plrRoot = player.Character:FindFirstChild("HumanoidRootPart") or player.Character.Parent:FindFirstChild("Torso") if rootPart and plrRoot then rootPart.CFrame = plrRoot.CFrame end AveragePlayer.Parent = workspace end if RandomCharacter == 2 then local AveragePlayer = CharacterFolder.Girl:Clone() AveragePlayer.Name = player.Name player.Character = AveragePlayer local rootPart = AveragePlayer:FindFirstChild("HumanoidRootPart") or AveragePlayer:FindFirstChild("Torso") local plrRoot = player.Character:FindFirstChild("HumanoidRootPart") or player.Character.Parent:FindFirstChild("Torso") if rootPart and plrRoot then rootPart.CFrame = plrRoot.CFrame end AveragePlayer.Parent = workspace end if RandomCharacter == 3 then local AveragePlayer = CharacterFolder.Troll:Clone() AveragePlayer.Name = player.Name player.Character = AveragePlayer local rootPart = AveragePlayer:FindFirstChild("HumanoidRootPart") or AveragePlayer:FindFirstChild("Torso") local plrRoot = player.Character:FindFirstChild("HumanoidRootPart") or player.Character.Parent:FindFirstChild("Torso") if rootPart and plrRoot then rootPart.CFrame = plrRoot.CFrame end AveragePlayer.Parent = workspace end tool:Destroy() end)