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 2 years ago
Edited 2 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 — 2y
0
no it wouldnt have Awsomeman511 30 — 2y

1 answer

Log in to vote
0
Answered by 2 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