Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I don't know if the way I am using this variable is correct. Can someone take a look?

So... I may be thinking this a little bit too hard.

local f = script.Parent.Spawner.Value

workspace.f.Part:Destroy()

The part isn't getting destroyed.

1 comment

0

Are you sure the part's parent is Value?

3 answers

✓ Accepted answer

You don't need workspace, only f. f is a reference to the object already.

f.Part:Destroy() -- This doesn't look right if it's an actual value, but I can't see your Workspace so I will assume it is correct.

Variable Link: http://robloxdev.com/articles/Variables

Examples:

local variableA = game.Workspace.Part

local variableB = 5

local variableC = "String"

local variableD = CFrame.new()

local variableE = Color3.new()

Ect...

If you're gonna index the value of variable 'f', use square parenthesis:

workspace[f].Part:Destroy()

2 comments

0

They are called square brackets.

0

Parenthesis is an alternative name for bracket

First, it would be

game.Workspace.f.Part:Destroy()

Second, what you have here is implying that inside the scripts parent there is a spawner with a value inside of it, and inside the value is a part.

Try this for the overall

local f = script.Parent -- assuming the parent of the script is what you want destroyed
wait(0)
game.Workspace.f:Destroy()

This discussion is preserved as it was. New answers, comments, and votes are closed.