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

How can I make it so the part is destroyed after 3 seconds?

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

Mouse.KeyDown:connect(function(Key)
	Key = Key:lower()
	if Key == 'r' then
		local S = Instance.new("Sound")
		S.SoundId = "rbxassetid://8373010808"
		S:Play()
		wait(1.2)
		local Part = Instance.new('Part', game.Workspace)
		Part.CanCollide = false
		Part.Anchored = true
		Part.BrickColor = BrickColor.new("Teal")
		Part.Material = "Neon"
		Part.CastShadow = false
		Part.Rotation = Vector3.new(0,0,0)
		Part.Size = Vector3.new (5,5,30)
		Part.CFrame = Player.Character.Torso.CFrame * CFrame.new(0,0,-19)
		
	end
end)

1 comment

0

wait(3) Part:Destroy(), however I'd recommend using DebrisService

1 answer

I don't really know about Input scripts but you can use :Destroy() which can destroy scripts ands parts

A example:

local part = script.Parent  --- Defines the part

local function Destroy() --- We make what does the part do
	wait(0.01) -- wait a bit
	part:Destroy() ---- This destroys the part
end

part.Touched:Connect(Destroy) --- We make It how the event starts

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