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

When getting of of a seat, HumanoidRootPart is opaque?

So. I'm trying to get a "Standing" seat where your character is laid out flat. But that works. But when I try stand up, however, my HumanoidRootPart is Opaque...

local player = nil 
local f = "" 

script.Parent.ChildAdded:connect(function() 
	if (script.Parent:findFirstChild("SeatWeld")) then 
		if (game.Players:GetPlayerFromCharacter(script.Parent.SeatWeld.Part1.Parent)) then 
			player = game.Players:GetPlayerFromCharacter(script.Parent.SeatWeld.Part1.Parent) 
			script.Parent.Parent.Name = ""
			script.Parent.OPEN.Transparency = 0
			script.Parent.CLOSED.Transparency = 1
			if (player.Character:findFirstChild("Shirt")) then 
				local s = Instance.new("Shirt")
				s.ShirtTemplate= player.Character.Shirt.ShirtTemplate 
				s.Parent = script.Parent.Parent 
			end 
			if (player.Character:findFirstChild("Pants")) then 
				local p = Instance.new("Pants")
				p.PantsTemplate= player.Character.Pants.PantsTemplate 
				p.Parent = script.Parent.Parent 
			end 
			for _,v in pairs(player.Character:GetChildren()) do 
				if (v.className == "Part") then 
					v.Transparency = 1 
					if (v.Name == "Torso") then 
						script.Parent.Parent.Torso.roblox.Texture = v.roblox.Texture 
					elseif (v.Name == "Head") then 
						script.Parent.Parent.Head.face.Texture = v.face.Texture 
						f = v.face.Texture 
						v.face.Texture = "" 
					end 
				elseif (v.className == "Hat") then 
					v.Handle.Transparency = 1 
				end 
			end 
			for _,v in pairs(script.Parent.Parent:GetChildren()) do 
				if (v.className == "Part") then 
					v.Transparency = 0 
					v.CanCollide = true 
				end 
			end 
		end 
	end 
end) 

script.Parent.ChildRemoved:connect(function(part) 
	if (player == nil) then return end 
	if not (script.Parent:findFirstChild("SeatWeld")) then 
			script.Parent.OPEN.Transparency = 1
			script.Parent.CLOSED.Transparency = 0
		if (player.Character.Humanoid.Health == 0) then return end 
		player.Character.HumanoidRootPart.Transparency = 1
--		script.Parent.Parent.Name = "Figure" 
		for _,v in pairs(script.Parent.Parent:GetChildren()) do 
			if (v.className == "Part") then 
				v.Transparency = 1 
				v.CanCollide = false 
				if (v.Name == "Head") then 
					v.face.Texture = "" 
				elseif (v.Name == "Torso") then 
					v.roblox.Texture = "" 
				end 
			elseif (v.className == "Shirt") or (v.className == "Pants") then 
				v:remove() 
			end 
		end 
		for _,v in pairs(player.Character:GetChildren()) do 
			if (v.className == "Part") then 
				v.Transparency = 0 
				if (v.Name == "Head") then 
					v.face.Texture = f 
				end 
			elseif (v.className == "Hat") then 
				v.Handle.Transparency = 0 
			end 
		end 
	end 
end) 

I was wondering if it would be possible to make this transparent, or stop it all together..

1 answer

✓ Accepted answer

Hence the HumanoidRootPart becomes visible once you get up, we will edit the ChildRemoving part of the script.

The problem is in this loop here:

        for _,v in pairs(player.Character:GetChildren()) do 
            if (v.className == "Part") then -- Keep in mind, HumanoidRootPart has a classname of Part
                v.Transparency = 0 

To avoid the HumanoidRootPart, Simply add a bypass around it so its transparency will not be set to 0.

Replace this:

 if (v.className == "Part") then

With this:

if (v.className == "Part") and (v.Name ~= "HumanoidRootPart") then

Hope this helps!

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