Destory is not a vaild member error

Hello devs Im making a safe zone and in this script it has a error called Destory is not a vaild member of LocalScript “Workspace.SafeZone.Unfilltered Weapon.Minecraft Diamond Sword.LocaScript”

Error Code =

local unfilldered_weapon = script.Parent:FindFirstChild("Unfilltered Weapon")

if unfilldered_weapon then
	for i, v in pairs(unfilldered_weapon:GetChildren()) do
		if v:IsA("Tool") then
			v.Enabled = false
			for i, parts in pairs(v:GetChildren()) do
				parts:Destory()
			end
		end
	end
end

What’s wrong with it?

Destroy is spelt “Destroy”, not “Destory”.

5 Likes

Also in the future you should use :ClearAllChildren() when you want to destory all children of an instance

local unfilldered_weapon = script.Parent:FindFirstChild("Unfilltered Weapon")

if unfilldered_weapon then
	for i, v in pairs(unfilldered_weapon:GetChildren()) do
		if v:IsA("Tool") then
			v.Enabled = false
			v:ClearAllChildren()
		end
	end
end
1 Like

local unfilldered_weapon = script.Parent:FindFirstChild(“Unfilltered Weapon”)

if unfilldered_weapon then
for i, v in pairs(unfilldered_weapon:GetChildren()) do
if v:IsA(“Tool”) then
v.Enabled = false
for i, parts in pairs(v:GetChildren()) do
parts:Destroy()
end
end
end
end

1 Like

You misspelled “Destroy”, you typed “Destory” instead. This would be the final code:

local unfilldered_weapon = script.Parent:FindFirstChild("Unfilltered Weapon")

if unfilldered_weapon then
	for i, v in pairs(unfilldered_weapon:GetChildren()) do
		if v:IsA("Tool") then
			v.Enabled = false
			for i, parts in pairs(v:GetChildren()) do
				parts:Destroy()
			end
		end
	end
end
1 Like

srry for all guys I didnt notice that

ty for new information

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.