How can I delete a part that I made with Instance.new?

local motor
...rest
Tool.Equiped:Connect(function()
  motor = Instance.new()
...rest
end)

Tool.Unequiped:Connect(function()
  motor:Destroy()
end)

Try this. It should work on a server script.
(Use the old method u did to set the motor parent (script.Parent.Parent.Torso)

1 Like

You could use a remote, or a joined loop, or a player count (thats useless though)

image

I think it should be

local motor
...rest
Tool.Equipped:Connect(function()
  motor = Instance.new()
...rest
end)

Tool.Unequipped:Connect(function()
  motor:Destroy()
end)

once tools are equipped, the become a child of the character that equipped them, so using the equipped event, you can get a character by using the tool.parent since the parent of the tool is the character after its equipped

Yeah, I’ll probably disable the autocorrect :smile:

Adding on to f0x,

local tool = script.Parent
local player = tool.Parent
-- the player is the character

or

script.Parent.Parent -- the character 

Could work too.
@CrazyGrapefruit32


Motor6D aint spawning, did I do something wrong (clearly, but what)?

under Instance.new set the motor.Parent to script.Parent.Parent.Torso

Use this one! The other is spelt incorrectly.

local motor
...rest
Tool.Equipped:Connect(function()
  motor = Instance.new("Motor6D")
...rest
end)

Tool.Unequipped:Connect(function()
  motor:Destroy()
end)
1 Like

Thank you both of yall this works! I’ll set it to solution for anyone that has a similar issue

You welcome, have any other issues? Dm me!