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

Disguise tool always teleports the player to where the morph Is, wondering why?

Hello, I made a disguise tool that whenever the ability Is activated, the player changes appearance, the way It changes the player Is simple, there are three characters I made that are Inside of a folder called "Characters" In ReplicatedStorage, when the ability Is activated, It will go to the folder and select a random character using math.random which then paste all of the assets to that said character, Inside of the current player model who activated It, It does work however the morph appears to teleport me to where the characters are currently placed

For example: I placed a NPC In A red checkpoint, and I spawned In a blue checkpoint, when I use the disguise tool and It selects the NPC In the red checkpoint, It teleports me there as well of morphing Into the NPC

script:

local tool = script.Parent
local Rep = game.ReplicatedStorage
local CharacterFolder = Rep.Characters
local char = tool.Parent
local RandomCharacter1Names = {
	"XxEpicGodxX",
	"JohnClan123",
	"TF2Fan123",
	"Happy_Goer",
	"Fjidnd",
	"HappyGoMan",
	"XxBroGamerxX",
	"Dad_WentToGetMilk3",
	"EpicMaster_232",
	"T5_ProGamer"
}
local RandomCharacter2Names = {
	"LisGaming_YT",
	"HappyFriend321",
	"CutieBun",
	"HotBun_YT",
	"FloppaLap",
	"CatLover123",
	"I_LoveCats321",
	"NerdGal",
	"Gal_YaLookingLike",
	"LoveHeartControl",
	"JeanGaming_YT123",
	"ILoveCats321",
	"BunCooker333",
	"TikTik_YT"
}

local RandomCharacter3Names = {
	"HelloThereMario323",
	"JaredSusHa",
	"Xx_AmongUs_xX",
	"XxGamerSlapxX",
	"Fnnjrfnjd",
	"TF2_Good",
	"coolGuy",
	"NormalSmores",
	"Too_CoolForSchool",
	"2_Cool4U"
}

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
		AveragePlayer.Humanoid.DisplayName = RandomCharacter1Names[math.random(1, #RandomCharacter1Names)]
	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
		AveragePlayer.Humanoid.DisplayName = RandomCharacter2Names[math.random(1, #RandomCharacter2Names)]
	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
		AveragePlayer.Humanoid.DisplayName = RandomCharacter3Names[math.random(1, #RandomCharacter3Names)]
	end
	tool:Destroy()
end)

1 answer

✓ Accepted answer

I see that you are still using my script. Try putting plrRoot before the line local RandomCharacter = math.random(1,3) and remove any other plrRoot lines after the line if RandomCharacter == 1 then.

1 comment

0

Thanks! It works!

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