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 4 years ago

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

function somethinghere:Fade(speed)
    print(somethinghere)
end

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 — 4y

3 answers

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

try doing

local somethinghere 
function somethinghere:Fade(speed)
        somethinghere = game.Workspace.Part.Name
print(somethinghere)
end

if this is what you mean then try it

Ad
Log in to vote
0
Answered by 4 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
4 years ago

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

local object

local function afunction ()
    object = Instance.new("Part") --Change the value to anything you want the object to be.
    object.Name = "TheObjectsName"
    --You might wanna change its properties here (size,color,anchored,colidable,etc.)
    object.Parent = workspace

    object = Instance.new("Part") --This will make a new instance but the instance made before will not disappear.
end

Answer this question