#how to delete summoned instances
26 messages · Page 1 of 1 (latest)
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)
Do you want to destroy something the player has or just the part they touched@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
Just remove the second condition and everything will be fine
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)
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()
it says unknown global 'Basepart'
send all the script
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)
I don't know what you're trying to do, are you trying to remove some extremity from the player?
so basically 1 block summons new instances and the block am trying to do is the block the destroys the other ones
this is the block that summons it
the block that destroys it wasn't made while the video was recorded
I assume you want the tool to destroy all objects?
no the tool was just there to carry it
its like lumber tycoon if you have heard of it
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)
bye