InTesting

Cake Gun

Jul 26th, 2020 (edited)
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.44 KB | None | 0 0
  1. print'https://pastebin.com/raw/z7tarq7m'
  2. --by CHL
  3.  
  4. --Converted with ttyyuu12345's model to script plugin v4
  5.  
  6. Tool0 = Instance.new("Tool")
  7. Part1 = Instance.new("Part")
  8. SpecialMesh2 = Instance.new("SpecialMesh")
  9. RemoteEvent5 = Instance.new("RemoteEvent")
  10. Sound6 = Instance.new("Sound")
  11. Tool0.Name = "Cake Gun"
  12. Tool0.Grip = CFrame.new(0, 0, 0.600000024, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  13. Tool0.GripPos = Vector3.new(0, 0, 0.600000024)
  14. Tool0.ToolTip = "Is it cake? You scream for you do not know. (Based on the cakeifier from Bloody Battle)"
  15. Part1.Name = "Handle"
  16. Part1.Parent = Tool0
  17. Part1.CFrame = CFrame.new(0, 0.5, 30, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  18. Part1.Position = Vector3.new(0, 0.5, 30)
  19. Part1.Size = Vector3.new(1, 1, 1)
  20. Part1.BottomSurface = Enum.SurfaceType.Smooth
  21. Part1.TopSurface = Enum.SurfaceType.Smooth
  22. SpecialMesh2.Parent = Part1
  23. SpecialMesh2.MeshId = "http://www.roblox.com/asset/?id=16211718"
  24. SpecialMesh2.TextureId = "http://www.roblox.com/asset/?id=16211592"
  25. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  26. script.Parent = Tool0
  27.  
  28. NLS([[
  29. local RE = script.Parent:WaitForChild('RemoteEvent',math.huge)
  30. local uis = game:GetService("UserInputService")
  31. local mouse = game:GetService("Players").LocalPlayer:GetMouse()
  32.  
  33. uis.InputBegan:Connect(function(a)
  34.     if a.UserInputType~=Enum.UserInputType.MouseButton1 then return;end;
  35.     RE:FireServer('Fire',mouse.Target,mouse.Hit)
  36. end)
  37. ]],script)
  38. RemoteEvent5.Parent = script
  39. Sound6.Name = "BulletFiringSound"
  40. Sound6.Parent = Tool0
  41. Sound6.SoundId = "rbxassetid://2641656639"
  42. Sound6.Volume = 1
  43. Tool0.Parent = owner.Character
  44. local RE = script:WaitForChild('RemoteEvent',math.huge)
  45. local ChangeIndex = function(a,b,c)
  46.     for d,e in next,b do
  47.         local _,f = pcall(function()a[d]=e;end);
  48.         if c and f then warn(f);end;
  49.     end
  50. end
  51.  
  52. local Bool = true;
  53.  
  54. local function wait(a)
  55.     if not a or a==0 then
  56.         return ({game:GetService("RunService").Stepped:Wait()})[2]
  57.     end
  58.     local b = 0;
  59.     while a>b do b+=wait()end
  60.     return b;
  61. end
  62.  
  63. local function TurnIntoCake(model)
  64.     for _,a in next,{'Left Arm';'Right Arm';'Left Leg';'Right Leg';'LeftUpperArm';'RightUpperArm';
  65.             'LeftUpperLeg';'RightUpperLeg';'UpperTorso';'Torso'}do
  66.         if model:FindFirstChild(a)then
  67.             model[a]:Destroy()
  68.         end;
  69.     end
  70.     for _,a in next,model:GetDescendants()do
  71.         if a:IsA'BasePart'or a:IsA'Decal'then
  72.             a.Transparency = 1
  73.             if a:IsA'BasePart'then
  74.                 a.Massless = true
  75.                 if a.Name~='Head'then
  76.                     a.CanCollide = false
  77.                 end
  78.             end
  79.         elseif a:IsA'Humanoid'then
  80.             a.PlatformStand = true
  81.             a.BreakJointsOnDeath = false
  82.             a:SetStateEnabled(Enum.HumanoidStateType.Dead,false)
  83.         end
  84.     end
  85.    
  86.    
  87.     if model:FindFirstChild'Head'then
  88.         local a = Instance.new("Tool",workspace)
  89.         a.Name = model.Name
  90.         a.GripPos = script.Parent.GripPos
  91.         pcall(function()
  92.         model.Parent = a;end)
  93.         local b = Instance.new("Part",a)
  94.         b.Transparency = 0
  95.         b.Massless = true
  96.         b.Position = model.Head.Position
  97.         b.Name = 'Handle'
  98.         b.Size = Vector3.new(1,1,1)
  99.         local z = true;
  100.         b.Touched:Connect(function(c)
  101.             if not c or not z then return;end;
  102.             local d = c:FindFirstAncestorWhichIsA'Model'
  103.             if not d or d==model then return;end;
  104.             if not game:GetService("Players"):GetPlayerFromCharacter(d)then return;end;
  105.             a.Parent = d
  106.             z = false
  107.         end)
  108.         model.Head.Size = Vector3.new(1,1,1)
  109.         local c = Instance.new("Weld",model.Head)
  110.         c.Part0 = model.Head
  111.         c.Part1 = b
  112.        
  113.         local d=Instance.new("SpecialMesh",b)
  114.         d.MeshId = 'http://www.roblox.com/asset/?id=16211718'
  115.         d.TextureId = 'http://www.roblox.com/asset/?id=16211592'
  116.         local Character
  117.         a.Unequipped:Connect(function()
  118.             wait()
  119.             if a.Parent:IsA'Backpack'then
  120.                 model.Parent = workspace;
  121.                 if Character then
  122.                 c.Part1 = Character:FindFirstChild'Head'
  123.                 end;
  124.             else
  125.                
  126.             end;
  127.             Character = nil
  128.         end)
  129.         a.Equipped:Connect(function()
  130.         pcall(function()model.Parent = a;end)
  131.            
  132.             Character = a.Parent
  133.            
  134.             c.Part1 =b
  135.         end)
  136.         if game:GetService("Players"):GetPlayerFromCharacter(model)then
  137.             game:GetService("Players"):GetPlayerFromCharacter(model).Chatted:Connect(function(g)
  138.                 local e = b:FindFirstChild('BillboardGui')
  139.                 if not e then
  140.                     e = Instance.new("BillboardGui")
  141.                     e.LightInfluence = 0
  142.                     e.MaxDistance = 100
  143.                     e.Size = UDim2.new(10,0,2)
  144.                     e.Parent = b;
  145.                     e.StudsOffset = Vector3.new(0, 2, 0)
  146.                 end
  147.                 local f = e:FindFirstChild'TextLabel'
  148.                 if not f then
  149.                     f = Instance.new("TextLabel")
  150.                     f.BackgroundTransparency = 1
  151.                     f.Size = UDim2.new(1,0,1)
  152.                     f.Font='Code'
  153.                     f.TextScaled = true
  154.                     f.TextColor3 = Color3.fromRGB(255, 255, 255)
  155.                     f.TextStrokeTransparency = 0
  156.                     f.Parent = e
  157.                 end
  158.                
  159.                 f.Text = g
  160.                
  161.             end)
  162.         end
  163.     end
  164.    
  165. end
  166.  
  167. local CachedBullet
  168. RE.OnServerEvent:Connect(function(a1,b,...)
  169.     local c = {...}
  170.     local d = {
  171.         Fire=function()
  172.             if not Bool then return;end;
  173.             if script.Parent.Parent:IsA('Backpack')then return;end;
  174.             local Bullet = CachedBullet
  175.             if not Bullet then
  176.                 Bullet = Instance.new("Part")
  177.                 ChangeIndex(Bullet,{
  178.                     Material = 'Neon';
  179.                     Anchored = true;
  180.                     CanCollide = false;
  181.                     Shape = 'Cylinder';
  182.                     Name = 'Cake_Gun_Bullet'
  183.                 })
  184.             end
  185.             Bullet.Color = Color3.new(math.random(),math.random(),math.random())
  186.             Bullet.Parent = nil;
  187.             if not c[2]then return;end;
  188.             local ori = script.Parent.Handle.Position
  189.             local epos = c[2].Position
  190.             local a2=RaycastParams.new()
  191.             a2.FilterType = Enum.RaycastFilterType.Blacklist
  192.             a2.FilterDescendantsInstances = {a1.Character}
  193.             local a = workspace:Raycast(ori,(epos-ori).unit*300,a2)
  194.             if not a then return;end;
  195.             Bool = false
  196.             Bullet.Size = Vector3.new((a.Position-ori).Magnitude,.1,.1)
  197.             Bullet.CFrame = CFrame.new(ori,a.Position) * CFrame.Angles(0,math.rad(90),0) * CFrame.new(Bullet.Size.X/2,0,0)
  198.             Bullet.Parent = workspace
  199.             script.Parent.BulletFiringSound:Play()
  200.             if a.Instance then
  201.                 local e = a.Instance
  202.                 local f = e:FindFirstAncestorWhichIsA'Model'
  203.                 if f then
  204.                     if f~=workspace and f:FindFirstChildWhichIsA'Humanoid'and f~=a1.Character and
  205.                         f.Parent==workspace then
  206.                         local i = game:GetService("Players"):GetPlayerFromCharacter(f)
  207.                         if i then
  208.                             if game.PlaceId==843468296 --and owner.UserId~=710232008
  209.                                 then
  210.                                 if i:FindFirstChildWhichIsA('PlayerGui') then
  211.                                     if not i:FindFirstChildWhichIsA('PlayerGui'):FindFirstChild'Cake_Gun_Permit_Gui'
  212.                                         then
  213.                                         local g = game:GetService("ReplicatedStorage"):FindFirstChild
  214.                                             'Cake_Gun_Permit_Gui'
  215.                                         if not g then
  216.                                             g = Instance.new("ScreenGui",game:GetService("ReplicatedStorage"))
  217.                                             g.Name = 'Cake_Gun_Permit_Gui'
  218.                                             g.ResetOnSpawn = false;
  219.                                             local h = Instance.new("Frame",g)
  220.                                             h.AnchorPoint = Vector2.new(1,1)
  221.                                             h.Position = UDim2.new(1,0,1,0)
  222.                                             h.Size = UDim2.new(.25,0,.25,0)
  223.                                             local i = Instance.new("TextButton",h)
  224.                                             i.Name = 'No'
  225.                                             i.Text = 'No'
  226.                                             i.Size = UDim2.new(.5,0,.5,0)
  227.                                             i.Position = UDim2.new(0,0,1,0)
  228.                                             local i = Instance.new("TextButton",h)
  229.                                             i.Name = 'Yes'
  230.                                             i.Text = 'Yes'
  231.                                             i.Size = UDim2.new(.5,0,.5,0)
  232.                                             i.Position = UDim2.new(.5,0,1,0)
  233.                                             local i = Instance.new("TextButton",h)
  234.                                             i.Name = 'a'
  235.                                             i.Text = 'Do you want to turn into cake?'
  236.                                             i.Size = UDim2.new(1,0,.5,0)
  237.                                             i.Position = UDim2.new(0,0,.5,0)
  238.                                             for _,i in next,g:GetDescendants()do
  239.                                                 i.BackgroundColor3 = Color3.fromRGB()
  240.                                                 i.BorderColor3= Color3.new(1,1,1)
  241.                                                 if h~=i then
  242.                                                     i.AnchorPoint = Vector2.new(0,1)
  243.                                                     i.Font='Code'
  244.                                                     i.TextScaled = true;
  245.                                                     i.TextColor3 = Color3.new(1,1,1)
  246.                                                 end
  247.                                             end
  248.                                         end
  249.                                         local h = g:Clone()
  250.                                         h.Parent = i:FindFirstChildWhichIsA('PlayerGui')
  251.                                         h.Frame.Yes.MouseButton1Click:Connect(function()
  252.                                             TurnIntoCake(f)
  253.                                             h:Destroy()
  254.                                         end)
  255.                                         h.Frame.No.MouseButton1Click:Connect(function()
  256.                                             h:Destroy()
  257.                                         end)
  258.                                     end;
  259.                                 end;
  260.                             else
  261.                                 TurnIntoCake(f)
  262.                             end
  263.                         else
  264.                             TurnIntoCake(f)
  265.                         end
  266.                     end
  267.                 end
  268.             end
  269.             wait(.2)
  270.             Bullet.Parent = nil
  271.             CachedBullet = Bullet
  272.             Bool = true
  273.            
  274.         end
  275.         }
  276.     d[b]()
  277. end)
Add Comment
Please, Sign In to add comment