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

How to change properties of a model?

I am trying to make an entire model transparent from steeping on a brick. I'm not sure how to do this though. Is it possible?

1 comment

2

use a for loop

2 answers

✓ Accepted answer
local Model 		= workspace:WaitForChild'model name here'
local Brick			= workspace:WaitForChild'name of brick here'
local Debounce 	= false


function changeTransparency(Value)
	if Model and Value and type(Value) == "number" then
		for i,v in next,Model:GetChildren() do
	
			if v.ClassName == "Part" then
				v.Transparency = Value
			end
	
		end
	
	end
end




Brick.Touched:connect(function(Part)
	if Part and Part.Parent.ClassName == 'Model' and Part.Parent:FindFirstChild'Humanoid' then
		if not Debounce then
		Debounce = true
		changeTransparency(1)

		wait(.5)
		Debounce = false
		end
	end
end)


basically just use a for loop to iterate through all the model's children and check if they are Part instances and change their Transparency property to 1

What I would do is have it select each part of that model and change its transparency. Inefficient script, but I'm not the best either. You could do something like this

Part.Transparency = 1
Parta.Transparency = 1

and so on, again, that's a horrible way to do it, but that's what I do. (If anyone else wants to show me a better way of doing this, please do!)

1 comment

0

I recommend the answer above yours for guidance.. :)

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