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

Variable inside function? Don't know how to call this

Asked by 5 years ago

It's hard to explain and I don't know what to call it, but this is what I am trying:

1function somethinghere:Fade(speed)
2    print(somethinghere)
3end

basically being able to change the somethinghere to any instance in the game.

0
So... like the thing changes into another thing thats not the original thing??? CjayPlyz 643 — 5y

3 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

try doing

1local somethinghere
2function somethinghere:Fade(speed)
3        somethinghere = game.Workspace.Part.Name
4print(somethinghere)
5end

if this is what you mean then try it

Ad
Log in to vote
0
Answered by 5 years ago

Well the thing is it's not a specific part, I just want it to find the instance that is getting used for the somethinghere.

Log in to vote
0
Answered by
CjayPlyz 643 Moderation Voter
5 years ago

I'm not sure what you mean but this might help:

01local object
02 
03local function afunction ()
04    object = Instance.new("Part") --Change the value to anything you want the object to be.
05    object.Name = "TheObjectsName"
06    --You might wanna change its properties here (size,color,anchored,colidable,etc.)
07    object.Parent = workspace
08 
09    object = Instance.new("Part") --This will make a new instance but the instance made before will not disappear.
10end

Answer this question