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

Attempt to index nil with 'Destroy'?

Asked by 3 years ago

i'm trying to use a remote event to destroy a basic part, which is a child of the player. here's the code:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
    local waa = player:FindFirstChild("CloudPower")
    wait()
    waa:Destroy()
end)
0
Was the part created in a local script? Averted_Vision 177 — 3y
0
was the part in a local script? if so then use this script: https://pastebin.com/raw/PzUMF9tn Sabertooth11123 38 — 3y

1 answer

Log in to vote
0
Answered by
Mroczusek 111
3 years ago

This error means that the object you're trying to destroy doesn't exist.

I think the issue here might be either that: - You're pointing to the wrong path, so the script doesn't see the object, - You've instanced (created) the script in a localscript.

The fix is either: - Check if the path to the "CloudPower" object is correct, - Create "CloudPower" with a serverscript or fire a remotevent in order to create the "CloudPower" object.

Hope I helped!

0
yes, it is in a local script! i thought about that earlier. i'll have to move the script that makes the part into the server script Realbluedrago 8 — 3y
Ad

Answer this question