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

is there a way to delete local parts?

Asked by
Benqazx 108
9 years ago
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?

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. Necrorave 560 — 9y
0
umm let me try that Benqazx 108 — 9y
0
For future reference, it's generally better to put the parts in game.Workspace.CurrentCamera. ChemicalHex 979 — 9y

1 answer

Log in to vote
3
Answered by 9 years ago
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.

0
yes i know i spelt it winner wrong its because i have another message names winnermessage so called this one winermessage Benqazx 108 — 9y
0
Alright, I hope this helped you. If so, rate me a +1 ;) thanks! RevergeHelps 63 — 9y
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 Benqazx 108 — 9y
0
My comment or Necro's? ChemicalHex 979 — 9y
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. RevergeHelps 63 — 9y
Ad

Answer this question