#how to delete summoned instances

26 messages · Page 1 of 1 (latest)

turbid sleet
#

so currently the instance is named "Part" but I don't know how to really delete it without it deleting the player

#

heres my code rn trying to delete the instance but not working

#

game.Workspace.Part.Touched:Connect(function(basePart)
local humanoid = basePart.Parent:FindFirstChildOfClass("Humanoid")
if humanoid and humanoid.Parent ~= game.Players.LocalPlayer.Character and basePart.Name == "Part" then
basePart:Destroy()
end
end)

barren hearth
#

Do you want to destroy something the player has or just the part they touched@turbid sleet

turbid sleet
#

this summons the instance

#

game.Workspace.Part.Touched:Connect(function(basePart)
if basePart.Parent:FindFirstChild("Humanoid") then
if game.Players:GetPlayerFromCharacter(basePart.Parent) then
local myPart = Instance.new("Part")
myPart.Size = Vector3.new(1, 1, 1)
myPart.Position = Vector3.new(0, 10, 6)
task.wait(1)

    end
end

end)

#

I just want to destroy the instance but only when it touches the part it self

barren hearth
#

Just remove the second condition and everything will be fine

turbid sleet
#

in this?

#

game.Workspace.Part.Touched:Connect(function(basePart)
local humanoid = basePart.Parent:FindFirstChildOfClass("Humanoid")
if humanoid and humanoid.Parent ~= game.Players.LocalPlayer.Character and basePart.Name == "Part" then
basePart:Destroy()
end
end)

barren hearth
#

or you can use

local hum = basePart:FindFirstChild("Humanoid")

if not hum or hum.Health == 0 then return end

local newPart = insntace.new("Part", workspace)
#

wait(1)
newPart:Destroy()

turbid sleet
#

it says unknown global 'Basepart'

barren hearth
#

send all the script

turbid sleet
#

game.Workspace.Part.Touched:Connect(function(basePart)
local humanoid = basePart.Parent:FindFirstChildOfClass("Humanoid")
if humanoid and humanoid.Parent ~= game.Players.LocalPlayer.Character and basePart.Name == "Part" then
basePart:Destroy()
end
end)

barren hearth
#

I don't know what you're trying to do, are you trying to remove some extremity from the player?

turbid sleet
#

so basically 1 block summons new instances and the block am trying to do is the block the destroys the other ones

#

the block that destroys it wasn't made while the video was recorded

barren hearth
#

I assume you want the tool to destroy all objects?

turbid sleet
#

no the tool was just there to carry it

#

its like lumber tycoon if you have heard of it

barren hearth
#
game.Workspace.Part.Touched:Connect(function(basePart)
    local humanoid = basePart.Parent:FindFirstChild("Humanoid")

local partInfo = BasePart
    if humanoid and humanoid.Health > 0 then
        if partInfo.Name == "Part" then
        partInfo:Destroy()
        end
    end
end)

turbid sleet
#

thank you

#

I also need to go to sleep it's midnight cya tomorrow

barren hearth
#

bye