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

Script changes transparency of a models children?[SOLVED]

I have a script that is supposed to change the transparency of a group of parts children but at the moment it changes 1 part at a time and since there are tons of parts it takes forever.

So I was wondering if there was a way to change all the children of the model at 1 time?

Heres the code ive got so far!

local Button = script.Parent.PurchaseButton
local NotActivated = true

Button.Touched:Connect(function()
	if NotActivated == true then
		print("Activated")
		NotActivated = false
		Button.Transparency = 1
		for i,Parts in pairs(script.Parent.MakeshiftMiner:GetChildren()) do
			if Parts:IsA("Part" or "UnionOperation" or "WedgePart") then
				for i = 1, 0, -.1 do
					wait()
					Parts.Transparency = i
				end
			end
		end
	end
end)

Thank you for your time :)

3 comments

0

You can just union all the parts together

0

Problem is line 10; You have to check each one individually. (i.e. if v:IsA('Part') or v:IsA('WedgePart') then -- code end) Also, use BasePart instead; it covers all the parts. :)

1 answer

You simply can't.

Code can't run at exactly the same time the speed of electricity is not instantaneous, but you can get close enough, so that it seems like it is instant. You simply.... Remove the wait(), lets say there are 50 parts - wait() is 0.01 seconds or 0.03 not too sure, let's go with 0.03. If there are 50 parts and you include a wait then that takes 0.5 seconds to finish, which can be seen. So if you remove the wait it would be quite faster. Speed is also affected by how good the client's computer is, but remove the wait should make it seem instant.

1 comment

0

I actually got it working, so all of the parts become visible at the same time :)

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