Removing modifications made to Character

Hi!
Recently, I was stuck on a problem, and I kinda solved it with the help of multiple people (thank you btw).
But, instead of cloning the character like what I wanted in my previous post, I just want to reset the modifications made to the character WITHOUT :LoadCharacter() or killing the player.
The reason why I want the player to not actually die (aka having the charcter health = 0) is because weird bugs appear/happen.

SCRIPT:

local Anti = script.Parent.Part
local particles = script.Parent.ParticleEmitter
local spawnPart = script.Parent.SpawnPart.CFrame

Anti.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local char = hit.Parent
		local clonedEmitter = particles:Clone()

		clonedEmitter.Parent = char.HumanoidRootPart
		clonedEmitter.Enabled = true
		wait(1)

		for _, charPart in pairs(char:GetChildren()) do --the modifications begin
			if charPart:IsA("BodyColors") then
				charPart.HeadColor3 = Color3.fromRGB(86, 86, 86)
				charPart.LeftArmColor3 = Color3.fromRGB(86, 86, 86)
				charPart.RightArmColor3 = Color3.fromRGB(86, 86, 86)
				charPart.LeftLegColor3 = Color3.fromRGB(86, 86, 86)
				charPart.RightLegColor3 = Color3.fromRGB(86, 86, 86)
				charPart.TorsoColor3 = Color3.fromRGB(86, 86, 86)
			elseif charPart:IsA("Clothing") then
				charPart:Remove()
			elseif charPart:IsA("BasePart") then
				charPart.Anchored = true
				charPart.Color = Color3.fromRGB(84, 84, 84)
				charPart.Material = Enum.Material.Slate
			end
		end

		wait(0.25)
		clonedEmitter.Enabled = false
		wait(0.5)
		clonedEmitter:Remove()
		wait(1)
		char:PivotTo(spawnPart) --player "spawns" to a new spot
	end
end)

VIDEO:

1 Like

First off I would get their HumanoidDescription before hand to save their appearance and then after unanchor them, then use ApplyDescription to restore their clothing, and lastly set their body material back to plastic.

1 Like

The restore works! Although the clothing doesn’t. Here’s what I wrote.

local Anti = script.Parent.Part
local particles = script.Parent.ParticleEmitter
local spawnPart = script.Parent.SpawnPart.CFrame
local players = game:GetService("Players")

Anti.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local char = hit.Parent
		local clonedEmitter = particles:Clone()

		clonedEmitter.Parent = char.HumanoidRootPart
		clonedEmitter.Enabled = true
		wait(1)

		for _, charPart in pairs(char:GetChildren()) do
			if charPart:IsA("BodyColors") then
				charPart.HeadColor3 = Color3.fromRGB(86, 86, 86)
				charPart.LeftArmColor3 = Color3.fromRGB(86, 86, 86)
				charPart.RightArmColor3 = Color3.fromRGB(86, 86, 86)
				charPart.LeftLegColor3 = Color3.fromRGB(86, 86, 86)
				charPart.RightLegColor3 = Color3.fromRGB(86, 86, 86)
				charPart.TorsoColor3 = Color3.fromRGB(86, 86, 86)
			elseif charPart:IsA("Clothing") then
				charPart:Remove()
			elseif charPart:IsA("BasePart") then
				charPart.Anchored = true
				charPart.Color = Color3.fromRGB(84, 84, 84)
				charPart.Material = Enum.Material.Slate
			end
		end

		wait(0.25)
		clonedEmitter.Enabled = false
		wait(0.5)
		clonedEmitter:Remove()
		wait(1)
		local plr = players:GetPlayerFromCharacter(char)
		local id = plr.UserId
		local appearance = players:GetHumanoidDescriptionFromUserId(id)
		
		for _, charPart in pairs(char:GetChildren()) do
			if charPart:IsA("BasePart") then
				charPart.Anchored = false
				charPart.Material = Enum.Material.Plastic
			end
		end
		char.Humanoid:ApplyDescription(appearance)
		char:PivotTo(spawnPart)
	end
end)

EDIT: Nevermind, fixed it. It was a bug on Roblox’s end.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.