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

How can I select everything in the workspace through a script?

How could I for example select everything in the workspace to change it's transparency through a script? Or what can I use to make a script that'll do that.

I've tried to make it once but it didn't work and I don't understand what is wrong, could anybody help me?

player = script.Parent.Parent 
Mouse = player:GetMouse() 
children = workspace.lemodel:GetDescendants()


game.Players.LocalPlayer:GetMouse().KeyDown:Connect(function(KeyPressed)
	if KeyPressed == "f" then
	for index, descendant in pairs(children) do
	wait(0.5)
	children.Transparency = 0.1
	wait(0.5)
	children.Transparency = 0.2
	wait(0.5)
	children.Transparency = 0.3
	wait(0.5)
	children.Transparency = 0.4
	wait(0.5)
	children.Transparency = 0.5
	wait(0.5)
	children.Transparency = 0.6
	wait(0.5)
	children.Transparency = 0.7
	wait(0.5)
	children.Transparency = 0.8
	wait(0.5)
	children.Transparency = 0.9
	wait(0.5)
	children.Transparency = 1
	end
end
end)

1 comment

1

workspace:GetDescendants

1 answer

✓ Accepted answer

Replace all the children.Transparency = ... with descendant.Transparency = ...

You're changing a non-existant property of a table right now, not of the child selected in the for loop.

I also suggest moving children = workspace.lemodel:GetDescendants() into the function, instead of outside of it. The children might get modified but it won't update the list of descendants.

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