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

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

Asked by
Pvzw 19
5 years ago

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.

0
Are you sure the part's parent is Value? radusavin366 617 — 5y

3 answers

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

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...

Ad
Log in to vote
1
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago

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

workspace[f].Part:Destroy()
0
They are called square brackets. Fragmentation123 226 — 5y
0
Parenthesis is an alternative name for bracket Rare_tendo 3000 — 5y
Log in to vote
0
Answered by 5 years ago

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()

Answer this question