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

Why can this script not remove the touchinterest from a tool inside workspace?

Asked by 4 years ago
workspace.Items.ChildAdded:Connect(function(Item)
    Item:FindFirstChild("TouchInterest"):Destroy()
end)



workspace.ChildAdded:Connect(function(Child)
    if Child:IsA("Tool") then
        wait()
        Child.Parent = workspace.Items
    end
end)

all it gives is

 22:53:41.851 - ServerScriptService.TouchRemover:2: attempt to index a nil value
22:53:41.852 - Stack Begin
22:53:41.853 - Script 'ServerScriptService.TouchRemover', Line 2
22:53:41.853 - Stack End
0
Try WaitForChild instead of FindFirstChild on line 2 Lazarix9 245 — 4y
0
Pretty sure the touch interest gets removed when it's out of your hand, and why do you need to delete it? User#24403 69 — 4y
0
Disconnecting a Touch Event also invalidates its TouchInterest object. Fate2Seal 5 — 4y
0
@incapaxx e to pick up system Thesquid13 301 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Like @Lazarix9 said, you should be using WaitForChild() when using ChildAdded especially in workspace. Look at this guide on the ChildAdded event.

0
The item is already loaded when parented to the tools folder. Thesquid13 301 — 4y
Ad

Answer this question