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

instance that adds parts after deletion ?

Asked by 3 years ago

i am trying to make a script that adds a part after deleting a part by pressing the "delete" key ,this is in a local script


local UserInputService = game:GetService("UserInputService") local part = game.Workspace.Part UserInputService.InputBegan:connect(function(input) if input.KeyCode == Enum.KeyCode.Delete then part:Destroy() end end)

thank you

0
Do you want it to show up to everyone or just the player? User#39832 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago
--[[
make an event that fires when it destroys
]]

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.Delete then
    local part = game.Workspace:FindFirstChild'Part' or nil
    if part then
            part:Destroy()
        game.ReplicatedStorage.Events.RemakePart:FireServer() 
    end
    end
end)

--[[
put this in a server script somewhere
]]

game.ReplicatedStorage.Events.RemakePart.OnServerEvent:Connect(function()
    Instance.new('Part', game.Workspace).Position = Vector3.new(0,0,0) -- make part and put position u want
end)
0
event:FireServer() after you destroy it --[[line 12 in my script]] https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events BulletproofVast 1033 — 3y
0
Only the player that deleted the part will see the part delete! User#39832 0 — 3y
Ad

Answer this question