Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

is there a way to delete local parts?

repeat wait() 
until game.Workspace:FindFirstChild("WinerMessage")~= nil
player = game.Players:GetChildren()
for i,v in pairs(player) do
    local playercharacter = v.Character
        if game.Workspace:FindFirstChild("WinerMessage")~= nil then
			playercharacter.Humanoid.LocalBin:Destroy()
end
end

my code ^ -- it wont delete the local parts. i made a script that gives local parts to all the players. i want the local parts to be destroyed if something called 'WinerMessage' pops up in workspace. so basically if a message pops up in workspace names WinerMessage all the local parts should get destroyed all the local parts from each player. i place my local parts in players humanoid. is there a way to delete them?

3 comments

0

Why not use the same local script that creates them? Have somehing within it that constantly checks for "WinerMessage" and deletes the parts if it exists.

0

umm let me try that

0

For future reference, it's generally better to put the parts in game.Workspace.CurrentCamera.

1 answer

✓ Accepted answer
game.Workspace.ChildAdded:connect(function(object)
if object.Name == "WinerMessage" then
for i,plr in pairs(game.Players:GetChildren()) do
if plr and plr.Character and plr.Character:FindFirstChild("Humanoid") ~= nil and plr.Character.Humanoid:FindFirstChild("LocalBin") then
plr.Character.Humanoid.LocalBin:Destroy()
end
end
end
end)

I have no access in studio to test this but it should work fine. If anything is added to workspace then it will destroy it if the name is "WinerMessage" By the way, you spelt winner incorrectly.

5 comments

0

yes i know i spelt it winner wrong its because i have another message names winnermessage so called this one winermessage

0

Alright, I hope this helped you. If so, rate me a +1 ;) thanks!

0

i got the script right i just placed it in different place ^ this helped aswell and the comment on the question helped aswell. thank you guys

0

My comment or Necro's?

0

The method I've given you is much more efficient as of running a loop the entire time the server is running could cause lag spikes and possible delay in your game.

This discussion is preserved as it was. New answers, comments, and votes are closed.