Advertisement
justneed

ctrl + key to spawn part and delete

Dec 9th, 2024
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | Gaming | 0 0
  1. local plr =  game:GetService("Players").LocalPlayer
  2.  
  3. local function sp()
  4.     local mouse   = plr:GetMouse()
  5.     local tp      = mouse.Hit+Vector3.new(0,0,0)
  6.     tp            = CFrame.new(tp.X,tp.Y,tp.Z)
  7.     local part    = Instance.new("Part")
  8.     part.Parent   = game:GetService("Workspace")
  9.     part.Anchored = true
  10.     part.CFrame   = tp
  11. end
  12.  
  13. local function dp()
  14.     local mouse  = plr:GetMouse()
  15.     local tp     = mouse.Hit+Vector3.new(0,0,0)
  16.     tp           = CFrame.new(tp.X,tp.Y,tp.Z)
  17.     local target = mouse.Target
  18.     if target:IsA("BasePart") then
  19.         target:Destroy()
  20.     end
  21. end
  22.  
  23. game:GetService("UserInputService").InputBegan:Connect(function(i, gay)
  24.     local ctrl = game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftControl)
  25.     if i.KeyCode == Enum.KeyCode.Z and not gay then
  26.         if ctrl then
  27.             sp()
  28.         end
  29.     elseif i.KeyCode == Enum.KeyCode.X and not gay then
  30.         if ctrl then
  31.             dp()
  32.         end
  33.     end
  34. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement