Why doesn't this script get the transparency of the parts?

  1. What do you want to achieve? a script that makes all invisible players visible.

  2. What is the issue? when the code reaches the lines if parts.Transparency == 1 then it stops working (i’ve used print to find the part where it stops working and this was the line where the prints stopped)
    `

  3. What solutions have you tried so far? none since I dont understand the issue with the line

all help is appreciated

-- services, variables and functions
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local player = game.Players.LocalPlayer
local character = player.Character

--code
UserInputService.InputBegan:Connect(function(input, gameprocessed)
	if gameprocessed then return end
	if input.KeyCode == Enum.KeyCode.X then
		
		for i, v in pairs(workspace:GetChildren()) do
			if v:IsA("Model") then
				if v.Humanoid then
					local parts = v:GetDescendants()
					if parts.Transparency == 1 then
						parts.Transparency = 0.5

					end
				end
			end
		end
	end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

2 Likes

GetDescendants returns a table of the descendants and not one as if they were all, you must go through the table that it gives

-- services, variables and functions
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local player = game.Players.LocalPlayer
local character = player.Character

--code
UserInputService.InputBegan:Connect(function(input, gameprocessed)
	if gameprocessed then return end
	if input.KeyCode == Enum.KeyCode.X then
		for i, v in pairs(workspace:GetChildren()) do
			if v:IsA("Model") and v:FindFirstChild("Humanoid") then
				for _, Part in pairs(v:GetDescendants()) do
					if Part:IsA("BasePart") and Part.Transparency == 1 then
						Part.Transparency = 0.5
					end
				end
			end
		end
	end
end)
2 Likes