Transparency Bug

Whenever I set my transparency from 0 to 99 it replaces my torso with a ‘part’, does anyone know why?

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")

local TextBox = script.Parent

TextBox.FocusLost:Connect(function(Return)
	if not Return then
		return
	end

	if TextBox.Text:match("^%d+$") then
		local Transparency = tonumber(TextBox.Text) / 100 -- Assuming the input is a percentage value (0-100)
		Transparency = math.clamp(Transparency, 0, 1) -- Clamping the value between 0 and 1

		for _, Part in ipairs(Character:GetDescendants()) do
			if Part:IsA("BasePart") then
				if Part.Name == "Torso" then
				else
					Part.Transparency = Transparency -- Set other parts' transparency based on the input
				end
			end
		end
	end
end)

Its whenever anything is transparent, so if I were to set it anywhere form 0 to 99 that ‘part’ will be there.

Maybe by any chance that is the HumanoidRootPart since you are in R6 and the HumanoidRootPart is the same as the torso but invisible? Idk

Yup. I rewatched the video and it seems your code is changing the HRP. You should add a check to make sure it isn’t the HumanoidRootPart.

1 Like

I’m dumb lmao, doing that worked lol

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")

local TextBox = script.Parent

TextBox.FocusLost:Connect(function(Return)
	if not Return then
		return
	end

	if TextBox.Text:match("^%d+$") then
		local Transparency = tonumber(TextBox.Text) / 100 -- Assuming the input is a percentage value (0-100)
		Transparency = math.clamp(Transparency, 0, 1) -- Clamping the value between 0 and 1

		for _, Part in ipairs(Character:GetDescendants()) do
			if Part:IsA("BasePart") and Part.Name ~= "Torso" and Part.Name ~= "HumanoidRootPart" then
				Part.Transparency = Transparency -- Set other parts' transparency based on the input
			end
		end
	end
end)
1 Like