I want to change the transparency of house 1 to 0 transparency in a “for i and v in pairs do code”
But when i want to do v.game.transparency it doesn’t seem to want to change them (dosent even come up for quick code)
I know i could do
Local house1 = {game.workspace.house.part}
But i just want to do get children then set the transparency
(Note when i do print(v) it comes up with all the parts) so it knows the children are all the parts.
(Note there are about 10 parts in the house folder)
Can’t you just do v.Transparency to get the transparency property to then change? If no all children are parts, you’ll need to use an if statement that skips that child if it’s not a part
I’m pretty sure your problem is “game.” You can’t set the transparency of the world and it seems like you are looking for something named game inside of the parts you are looping through. You can use FindFirstChild() if you are trying to find an instance named game, which probably should have the name changed so it isn’t confused with the world. I would also check to make sure you are changing the transparency with :IsA() to make sure you are changing the transparency of BaseParts because you don’t want to run into an error.
v should be the instance that you are looping through and i should be the index.
Example:
for i, v in pairs(house1) do
if v:IsA("BasePart") then
v.Transparency = 0
end
end
local house = game.workspace:WaitForChild("house")
for i, o in pairs(house:GetChildren()) do
if o:IsA("BasePart") or o:IsA("Decal") then
o.Transparency = 1
end
end
Because Roblox’s quick code thing doesn’t know what v is interms of instance, You can do v.Transparency if you yourself know that they’re all parts, if the instance doesn’t have a Transparency Property, it’ll just error, simple as that
Could you show me the error message more clearly? Like using the inbuilt snipping tool for windows. Using your phone is hard as I can’t see the error message due to the light.
Show me the explorer menu containing your house and the instances.
Also, let’s clean this up. You could just do “workspace” as it’s a predefined variable by Roblox. Second use WaitForChild(), which waits for the model to load before continuing the thread.
Third, check if your parts exist and are BaseParts. I’d do something like this.
local house = workspace:WaitForChild(“House”)
for _, part in pairs(house:GetChildren()) do
if (part and part:IsA("BasePart")) then
part.Transparency = 0
end
end
local house = game.workspace:WaitForChild("house")
for i, o in pairs(house:GetChildren()) do
if o:IsA("BasePart") or o:IsA("Decal") then
o.Transparency = 1
end
end
And the reason it was “o” is because thats what he used in the loop instead of v, to make it more clear here:
local house = game.workspace:WaitForChild("house")
for i, part in pairs(house:GetChildren()) do
if part:IsA("BasePart") or part:IsA("Decal") then
part.Transparency = 1
end
end