Ad
Log in to vote
0

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

Asked by 6 months ago
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)
0
wait(3) Part:Destroy(), however I'd recommend using DebrisService greatneil80 2607 — 6mo

1 answer

Log in to vote
0
Answered by 6 months ago
Edited 6 months ago

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
Ad

Answer this question