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

Disguise tool not changing Into a different character?

Asked by 2 years ago

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)

1 answer

Log in to vote
1
Answered by 2 years ago

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)
0
Also if you want the name of the character to be not the usernane and actually in disguise, edit the Character’s Display name in the Humanoiid by adding a new line and type “AveragePlayer.Humanoid.DisplayName = “Type any name here” T3_MasterGamer 2189 — 2y
0
It appears to say "Player Is not a valid member of DataModel "game" imnotaguest1121 362 — 2y
0
Nevermind It worked! I just founded out that In line 6 you typed "game.players" you accidently made the P lowercase imnotaguest1121 362 — 2y
0
ye lol T3_MasterGamer 2189 — 2y
Ad

Answer this question