Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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

0
this is obviously a troll Kaput_0 44 — 3y
0
????????????????????? what????? im so confuzed?????????????? botw_legend 502 — 3y
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!) ashpash1212 2 — 3y
0
Oh, I am sorry I did not see that DemGame had already posted this answer. I wish you luck on your scripting journey! ashpash1212 2 — 3y

5 answers

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

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
Ad
Log in to vote
0
Answered by
DemGame 271 Moderation Voter
3 years ago

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
Log in to vote
0
Answered by
Alphexus 498 Moderation Voter
3 years ago
Edited 3 years ago

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
0
This works btw. Some people are trolling by downvoting it. Try it out! I promise you it works. Alphexus 498 — 3y
0
so those downvotes are trolls? Noxcitrus 2 — 3y
Log in to vote
-1
Answered by 3 years ago
Edited 3 years ago
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 :/

0
what if the transparency is 0 or 0.3 or 0.5 or 0.8 or 0.63? botw_legend 502 — 3y
0
also if the part doesn't have the Proportie Transparency then that script will run an error botw_legend 502 — 3y
0
Invalid global "Part". Please watch the script anaylsis User#30567 0 — 3y
0
It was an example obviously, he would need the variables LetalNightmare 99 — 3y
View all comments (2 more)
0
Fixed it! LetalNightmare 99 — 3y
0
I tested it and it works! So there you go! UPVOTE ME! xd LetalNightmare 99 — 3y
Log in to vote
-1
Answered by 3 years ago
Edited 3 years ago

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.

0
this dosent work tbh Noxcitrus 2 — 3y

Answer this question