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

1st person viewer script wont clone clothing after death?

Heres the code :

local plr = game.Players.LocalPlayer
local RS = game:GetService("RunService")
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
	local model = Instance.new("Model")
	model.Parent = workspace.CurrentCamera
	model.Name = "BodyParts"
	local humanoid = Instance.new("Humanoid")
humanoid.Parent = model
	local fakela = char["Left Arm"]:Clone()
	fakela.Parent = model
fakela.Anchored = true
fakela.BrickColor = char["Left Arm"].BrickColor
fakela.Color = char:WaitForChild("Body Colors").LeftArmColor3																																											script:Destroy()
	local fakera = char["Right Arm"]:Clone()
fakera.Parent = model
fakera.Color = char:WaitForChild("Body Colors").RightArmColor3
fakera.Anchored = true
local fakell = char["Left Leg"]:Clone()
fakell.Parent = model
fakell.Anchored = true
fakell.BrickColor = char["Left Leg"].BrickColor
fakell.Color = char:WaitForChild("Body Colors").LeftLegColor3
local fakerl = char["Right Leg"]:Clone()
fakerl.Parent = model
fakerl.Color = char:WaitForChild("Body Colors").RightLegColor3
fakerl.Anchored = true
if char:FindFirstChild("Shirt") then
local fakeshirt = char:WaitForChild("Shirt"):Clone()
	fakeshirt.Parent = model
end
if char:FindFirstChild("Pants") then
local fakepants = char:WaitForChild("Pants"):Clone()
	fakepants.Parent = model
end
plr.CharacterAdded:Connect(function()
	if char:FindFirstChild("Shirt") then
		local fakeshirt = char:WaitForChild("Shirt"):Clone()
		fakeshirt.Parent = model
	end
	if char:FindFirstChild("Pants") then
		local fakepants = char:WaitForChild("Pants"):Clone()
		fakepants.Parent = model
	end
end)

for i,c in pairs(char:GetChildren()) do
	if c:IsA("CharacterMesh") then
		if c.BodyPart == Enum.BodyPart.LeftArm or c.BodyPart == Enum.BodyPart.RightArm or c.BodyPart == Enum.BodyPart.LeftLeg or c.BodyPart == Enum.BodyPart.RightLeg then
			local e = c:Clone()
			e.Parent = model
			end
	end
end
local function isFirstPerson()
	local camera = workspace.CurrentCamera
	local character = game:GetService("Players").LocalPlayer.Character or  game:GetService("Players").LocalPlayer.CharacterAdded
	if (character.Head.CFrame.p - camera.CFrame.p).magnitude < 1 then
		return true
	else
		return false
	end
end
local freelook = false
local function handleAction()
	if freelook == false then
		freelook = true
	else
		freelook = false
	end
	end
local UIS = game:GetService("UserInputService")
local CAS = game:GetService("ContextActionService")
UIS.InputBegan:connect(function(key)
	if UIS:GetFocusedTextBox() then return end
	if key.KeyCode == Enum.KeyCode.E then
		if freelook == false then
			freelook = true
		else
			freelook = false
		end
	end
end)
CAS:BindAction("Freelook",handleAction,false,"E")
RS.RenderStepped:connect(function()
	local isFirstPerson = isFirstPerson()
	if isFirstPerson == true then
		fakela.Transparency = 0
		fakera.Transparency = 0
		fakell.Transparency = 0
		fakerl.Transparency = 0
		if freelook == false then
		workspace.CurrentCamera.CameraType = Enum.CameraType.Attach
			workspace.CurrentCamera.CFrame = char.Head.CFrame
		else
			workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
		end
	else
		workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
		fakela.Transparency = 1
		fakera.Transparency = 1
		fakell.Transparency = 1
		fakerl.Transparency = 1
	end
	fakela.CFrame = char["Left Arm"].CFrame
	fakera.CFrame = char["Right Arm"].CFrame
	fakell.CFrame = char["Left Leg"].CFrame
	fakerl.CFrame = char["Right Leg"].CFrame
hum.Died:Connect(function()
	model:Destroy()
	end)
end)

This script is used in this game https://www.roblox.com/games/6994712610/fight-people-simulator

1 answer

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