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

Properties not changing for all parts?

So I'm making a spleef type game, and when the round ends + starts i run through all parts in a big model called spleefParts (which definitely contains all of the spleef parts, I've checked), and set the CanCollide = true and Transparency = 0. But sometimes after a round has ended, there might be the odd part which still has its taransparency = 1 which is not what I want. I need all of them to be reset. Here is the code:

	if inRound.Value == false then
		for i, v in pairs(spleefParts:GetChildren()) do
			v.CanCollide = true
			v.Transparency = 0
		end
	else
		for i, v in pairs(spleefParts:GetChildren()) do
			v.CanCollide = true
			v.Transparency = 0
		end
	end

Any help appreciated!

1 answer

I find it very odd that you check for inRound using an if statement but do the same thing anyways...

if inRound.Value == false then
    for i, v in pairs(spleefParts:GetChildren()) do
        v.CanCollide = true  -- you do the same thing below
        v.Transparency = 0
    end
else
    for i, v in pairs(spleefParts:GetChildren()) do
        v.CanCollide = true  -- yo do the same thing above!
        v.Transparency = 0
    end
end

This means that the parts will always be opaque. Im not entirely sure. You may have entered the script wrong here on the forum.

If you are using models inside of spleefparts, try using this:

    for i, v in pairs(spleefParts:GetDescendants()) do -- get descendants instead of get children
        v.CanCollide = true  -- you do the same thing below
        v.Transparency = 0
    end

4 comments

0

Well if he is actually using models, then he would get an error, as CanCollide and Transparency are no properties of Models. And that last loop would error aswell, for the same reasons

0

The reason I'm checking is because I have a timer that when the round starts, inRound = true, but when it ends, it = false. I check what inRound == in a GetPropertyChangedSignal.

0

Using GetDescendants(), because I'm using a part.Touched, doesnt work and returns the error CanCollide is not a property of Workspace.spleefParts.Part.TouchInterest

0

I'm also not using models inside of spleefparts, spleefparts IS a model.

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