Position is not a valid member of model even though its a part, help?

i want to see if the part is in range of another part but it says the position is not a valid member of a model even though it is a part
huh

heres the code:

if Destroy_Map == true then
for i, v in pairs(game.Workspace:GetDescendants()) do
	if v.Name ~= NonAffected_Parts[1] then
		if (script.Parent.Position - v.Position).magnitude <= ShockWave_Size*2 then

and the last line is bugging
script.Parent is a part

it worked before but to reduce lag i did some changes and then it does not work anymore

also this is my first post :confused: and im new to scripting

Are you sure it’s a part? Because I don’t see a BasePart check on that code.

heee

No like the part that’s referred as v in your code, it could be anything since it’s a descendant of Workspace.

1 Like

He’s using script.Parent to set the position…
Edit: Nevermind, looked closer and realized.

I’m talking about v.Position.

1 Like

oh yeah i forgot that line, im so dumb, thanks for your time

This should work.

if Destroy_Map == true then
for i, v in pairs(game.Workspace:GetDescendants()) do
 
	if v.Name ~= NonAffected_Parts[1] and v:IsA("BasePart") then
		if (script.Parent.Position - v.Position).magnitude <= ShockWave_Size*2 then
1 Like

Could you send us the entire script?

He already figured out the problem.

Oh sorry, I didn’t see. He should mark the answer!

1 Like