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

Why doesn't this simple code work?

Supposed to loop constantly changing the part's transparency:

a = game.Workspace:waitForChild("Part1")
Trans = a.Transparency
while true do
	wait(1)
	Trans = 1 
	wait(1)
	Trans = 0
end

2 answers

waitForChild() doesn't exist. 'trans' is equal to the value of transparency.

a = game.Workspace:WaitForChild("Part1")
while wait(1) do
	for i=0,1,.1 do
		 a.Transparency = i
	end
	wait(1)
	for i=1,0,-.1 do
		 a.Transparency = i
	end
end

1 comment

0

I was using a While Loop to show a friend the inefficiency of them at times

When you assign a number to a variable it clones the original number and any changes dont reflect.

When you assign an object to a variable it gives a reference to the number and any changes do reflect.

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