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

ive been watching this return tutorial on youtube... but i am confused. can someone help? (ANSWERED)

Asked by 3 years ago
Edited 3 years ago
--so this line of code:

local partReturned  = createPart(0.5,Color3.fromRGB(255, 0, 0),true)
partReturned.Color = Color3.fromRGB(0,255,0)

--shouldnt this create 2 parts?
-- if you make a variable of a function, shouldnt that make a part as well?

--can someone explain?

0
partReturned was only called once. After it was called, you changed it's colour. If you did "createPart(blah).Color = blah", then it would've called twice. ChristianTRPOC 64 — 3y
0
no it wouldnt have Awsomeman511 30 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

The code above wont create 2 parts. The createPart function only gets called once, then you assign a variable (partReturned) to the part that gets returned. Reading or writing the variable you assigned to the returned part doesn’t call the function again to create another part.

Ad

Answer this question