Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesn't this simple code work?

Asked by
Mystdar 352 Moderation Voter
8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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

Log in to vote
0
Answered by
drahsid5 250 Moderation Voter
8 years ago

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

0
I was using a While Loop to show a friend the inefficiency of them at times Mystdar 352 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

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.

Answer this question