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

How can I get this to destroy the part in a local script?

Asked by 3 years ago
Edited 3 years ago

all this is is a local script with the following code in;

script.Parent.Touched:Connect(function(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) then
        script.Parent:Destroy()
    end
end)

here is what it looks like in the explorer.

0
heres what it looks like in da explorer: https://www.imageupload.net/image/uhw.HUp3M Agent_EpicNoob 71 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

Hey!

The reason as to why your script isn't working is because you are using a LocalScript in Workspace. A localscript cannot function in workspace to destroy a part. Put it in StarterCharacterScripts Instead.

You will need to change the code, and this is how you would do it:

local NowEnteringPart = workspace.NowEntering -- NOTE! If you change where the part is located, make sure to change this as well!

NowEnteringPart.Touched:Connect(function(hit)
    NowEnteringPart:Destroy()
end)
0
Wow dude, thanks! I did not know that! Of course I'll accept your answer! Agent_EpicNoob 71 — 3y
0
No problem! RazzyPlayz 497 — 3y
Ad

Answer this question