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

how to detect if a part's Proporties has Transparensy?

so i need to know if there is transparency in the proporties i tried doing:

if workspace.Model.Transparency then
	print()
end

but it didn't work plz help

4 comments

0

this is obviously a troll

0

????????????????????? what????? im so confuzed??????????????

0

You didn't put anything in the print box, and try using this: if workpsace.Model.Transparency > 0 then print("Part is either semi-transparent or invisible!)

0

Oh, I am sorry I did not see that DemGame had already posted this answer. I wish you luck on your scripting journey!

5 answers

✓ Accepted answer

There are currently three classes with transparency. They are:

You can use the Instance:IsA function to detect if the item is one of the classes above. However, this needs to be hardcoded with every class that has transparency.

local TransparencyClasses = {"Decal", "ParticleEmitter", "BasePart"}

function CheckForTransparency(TransparentObject)
	for Index, TransparentClass in pairs(TransparencyClasses) do
		if Transparent:IsA(TransparentClass) then
			return true
		else
			return false
		end
	end
end

local Part = workspace.Part
local PartDecal = workspace.Decal
local Attachment = Part.Attachment

print(CheckForTransparency(Part))
print(CheckForTransparency(PartDecal))
print(CheckForTransparency(Attachment))
print(CheckForTransparency(workspace))

This will output

true
true
false
false

You need to specify which part inside of a model you would like to check the transparency of, as you cannot directly check the transparency of a model. If you want to check if an object has any transparency at all, here is what you can do:

if workspace.Model.Part.Transparency > 0 then
	print("Part is transparent.")
end

You can check for properties by doing:

local success = pcall(function()
	if part["Transparency"] then
		return true
	end
end)

if success then
	-- It has the property
end

2 comments

0

This works btw. Some people are trolling by downvoting it. Try it out! I promise you it works.

0

so those downvotes are trolls?

local Model = workspace.Model

for i, v in pairs(Model:GetChildren()) do
	if v:IsA("Part") and v.Transparency > 0 then
		print("Test")
	end
end

This should work, it basically loops inside the Model and gets everything inside it, then checks if the children is a "Part" and if it has "Transparency". And if its true it will print "Test" in the output. Correct me if im wrong, i did it without the Studio tho :/

6 comments

0

what if the transparency is 0 or 0.3 or 0.5 or 0.8 or 0.63?

0

also if the part doesn't have the Proportie Transparency then that script will run an error

0

Invalid global "Part". Please watch the script anaylsis

0

It was an example obviously, he would need the variables

0

Fixed it!

0

I tested it and it works! So there you go! UPVOTE ME! xd

Is this serious?

if (part name here).Transparency == (Transparency Level) then
    print("Success!")
end

You don't have a print statement, Thus not printing the line in the output.

1 comment

0

this dosent work tbh

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