Advertisement
Rufus14

Paintball!

Dec 17th, 2019
2,385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.43 KB | None | 0 0
  1. --By Rufus14
  2. --Converted with ttyyuu12345's model to script plugin v4
  3. function sandbox(var,func)
  4.     local env = getfenv(func)
  5.     local newenv = setmetatable({},{
  6.         __index = function(self,k)
  7.             if k=="script" then
  8.                 return var
  9.             else
  10.                 return env[k]
  11.             end
  12.         end,
  13.     })
  14.     setfenv(func,newenv)
  15.     return func
  16. end
  17. cors = {}
  18. mas = Instance.new("Model",game:GetService("Lighting"))
  19. Tool0 = Instance.new("Tool")
  20. Part1 = Instance.new("Part")
  21. SpecialMesh2 = Instance.new("SpecialMesh")
  22. Sound3 = Instance.new("Sound")
  23. LocalScript4 = Instance.new("LocalScript")
  24. RemoteEvent5 = Instance.new("RemoteEvent")
  25. Script6 = Instance.new("Script")
  26. Tool0.Name = "Paintball Gun"
  27. Tool0.Parent = mas
  28. Tool0.TextureId = "rbxasset://Textures/PaintballIcon.png"
  29. Tool0.Grip = CFrame.new(0, 0.400000006, 0.5, 1, 0, -0, 0, 0, 1, 0, -1, -0)
  30. Tool0.GripForward = Vector3.new(0, -1, 0)
  31. Tool0.GripPos = Vector3.new(0, 0.400000006, 0.5)
  32. Tool0.GripUp = Vector3.new(0, 0, -1)
  33. Tool0.ToolTip = "see: Paintball! by daxter33"
  34. Part1.Name = "Handle"
  35. Part1.Parent = Tool0
  36. Part1.CFrame = CFrame.new(-7.5, 2.5, -10.75, 0, 1, 0, 0, 0, -1, -1, 0, 0)
  37. Part1.Orientation = Vector3.new(90, 90, 0)
  38. Part1.Position = Vector3.new(-7.5, 2.5, -10.75)
  39. Part1.Rotation = Vector3.new(90, 0, -90)
  40. Part1.Size = Vector3.new(0.5, 5, 3)
  41. Part1.BottomSurface = Enum.SurfaceType.Smooth
  42. Part1.TopSurface = Enum.SurfaceType.Smooth
  43. Part1.FormFactor = Enum.FormFactor.Symmetric
  44. Part1.formFactor = Enum.FormFactor.Symmetric
  45. SpecialMesh2.Parent = Part1
  46. SpecialMesh2.MeshId = "rbxasset://fonts/PaintballGun.mesh"
  47. SpecialMesh2.TextureId = "rbxasset://textures/PaintballGunTex128.png"
  48. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  49. Sound3.Name = "Fire"
  50. Sound3.Parent = Part1
  51. Sound3.Pitch = 3
  52. Sound3.PlaybackSpeed = 3
  53. Sound3.SoundId = "rbxassetid://1240222815"
  54. LocalScript4.Parent = Tool0
  55. table.insert(cors,sandbox(LocalScript4,function()
  56. end))
  57. RemoteEvent5.Name = "paintball"
  58. RemoteEvent5.Parent = Tool0
  59. Script6.Parent = Tool0
  60. table.insert(cors,sandbox(Script6,function()
  61. --By Rufus14, based on daxter's Paintball! game
  62. players = game:GetService("Players")
  63. runservice = game:GetService("RunService")
  64. owner = nil
  65. character = nil
  66. tool = script.Parent
  67. handle = tool.Handle
  68. remote = tool:WaitForChild("paintball")
  69. equipped = false
  70. firesound = handle.Fire
  71. tool.Grip = tool.Grip * CFrame.new(0,0,-0.5)
  72. --
  73. remote.OnServerEvent:connect(function(plr, what, pos)
  74.     if plr == owner then
  75.         if what == "shoot" then
  76.             firesound:Play()
  77.             local paint = Instance.new("UnionOperation", character.Head)
  78.             local brickmesh = Instance.new("BlockMesh", paint)
  79.             paint.Size = Vector3.new(0.1,0.1, 4)
  80.             paint.BrickColor = character.Torso.BrickColor
  81.             paint.Anchored = true
  82.             paint.CanCollide = false
  83.             paint.CFrame = handle.CFrame * CFrame.new(0,-4.5,0)
  84.             paint.CFrame = CFrame.new(paint.Position, pos)
  85.             coroutine.wrap(function()
  86.                 local hitanything = false
  87.                 local turn = 0
  88.                 local hitafter = nil
  89.                 local positionafter = nil
  90.                 local surfaceafter = nil
  91.                 local howmuch = 0
  92.                 local function afterhit(WHO)
  93.                     local hum = WHO:findFirstChildOfClass("Humanoid")
  94.                     if hum then
  95.                         hum.Health = 0
  96.                         WHO:BreakJoints()
  97.                     end
  98.                 end
  99.                 while not hitanything and runservice.Stepped:wait() and howmuch < 500 do
  100.                     howmuch = howmuch + 1
  101.                     local ray = Ray.new(paint.Position, paint.CFrame.lookVector * 7)
  102.                     local hit, position, surface = workspace:FindPartOnRayWithIgnoreList(ray, {character})
  103.                     if hit then
  104.                         hitanything = true
  105.                         hitafter = hit
  106.                         positionafter = position
  107.                         surfaceafter = surface
  108.                         if hit.Parent:findFirstChildOfClass("Humanoid") then
  109.                             afterhit(hit.Parent)
  110.                         elseif hit.Parent.Parent:findFirstChildOfClass("Humanoid") then
  111.                             afterhit(hit.Parent.Parent)
  112.                         end
  113.                     end
  114.                     paint.CFrame = paint.CFrame * CFrame.new(0,0,-7)
  115.                     if turn < 90 then
  116.                         turn = turn + 0.01
  117.                         paint.CFrame = paint.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(-turn),0,0)
  118.                     end
  119.                 end
  120.                 if hitanything then
  121.                     if hitafter.Name ~= "PaintballSplat" then
  122.                         local paintballhahajokegetit = Instance.new("UnionOperation", character.Head)
  123.                         local ballmesh = Instance.new("SpecialMesh", paintballhahajokegetit)
  124.                         ballmesh.MeshType = "Sphere"
  125.                         paintballhahajokegetit.Size = Vector3.new(0.25,0.25,0.25)
  126.                         paintballhahajokegetit.Name = "PaintballSplat"
  127.                         paintballhahajokegetit.BrickColor = character.Torso.BrickColor
  128.                         paintballhahajokegetit.CFrame = CFrame.new(positionafter, positionafter + surfaceafter)
  129.                         paintballhahajokegetit:BreakJoints()
  130.                         local weldball = Instance.new("Weld", paintballhahajokegetit)
  131.                         weldball.C0 = hitafter.CFrame:toObjectSpace(paintballhahajokegetit.CFrame)
  132.                         weldball.Part0 = hitafter
  133.                         weldball.Part1 = paintballhahajokegetit
  134.                         game.Debris:AddItem(paintballhahajokegetit, 10)
  135.                     end
  136.                 end
  137.                 paint:destroy()
  138.             end)()
  139.         end
  140.     end
  141. end)
  142. tool.Equipped:connect(function()
  143.     owner = players:GetPlayerFromCharacter(tool.Parent)
  144.     character = owner.Character
  145.     --
  146.     local torso = character.Torso
  147.     local rootpart = character.HumanoidRootPart
  148.     -----
  149.     if character:findFirstChildOfClass("Pants") then
  150.         local lastid = Instance.new("StringValue", character:findFirstChildOfClass("Pants"))
  151.         lastid.Value = character:findFirstChildOfClass("Pants").PantsTemplate
  152.         lastid.Name = "lastid"
  153.         character:findFirstChildOfClass("Pants").PantsTemplate = ""
  154.     end
  155.     if character:findFirstChildOfClass("Shirt") then
  156.         local lastid = Instance.new("StringValue", character:findFirstChildOfClass("Shirt"))
  157.         lastid.Value = character:findFirstChildOfClass("Shirt").ShirtTemplate
  158.         lastid.Name = "lastid"
  159.         character:findFirstChildOfClass("Shirt").ShirtTemplate = ""
  160.     end
  161.     for i,v in pairs(character:GetChildren()) do
  162.         if v.ClassName == "Accessory" or v.ClassName == "Hat" then
  163.             if v:findFirstChild("Handle") then
  164.                 v:findFirstChild("Handle").Transparency = 1
  165.             end
  166.         end
  167.     end
  168.     ---
  169.     local blockmesh = Instance.new("BlockMesh", torso)
  170.     blockmesh.Name = "PaintballBlockMesh"
  171.     -----
  172.     local lastcolor = Instance.new("StringValue", character["Right Arm"])
  173.     lastcolor.Value = tostring(character["Right Arm"].BrickColor)
  174.     lastcolor.Name = "lastcolor"
  175.     character["Right Arm"].BrickColor = BrickColor.Black()
  176.     --
  177.     local lastcolor = Instance.new("StringValue", character["Left Arm"])
  178.     lastcolor.Value = tostring(character["Left Arm"].BrickColor)
  179.     lastcolor.Name = "lastcolor"
  180.     character["Left Arm"].BrickColor = BrickColor.Black()
  181.     --
  182.     local lastcolor = Instance.new("StringValue", character["Left Leg"])
  183.     lastcolor.Value = tostring(character["Left Leg"].BrickColor)
  184.     lastcolor.Name = "lastcolor"
  185.     character["Left Leg"].BrickColor = BrickColor.Black()
  186.     --
  187.     local lastcolor = Instance.new("StringValue", character["Right Leg"])
  188.     lastcolor.Value = tostring(character["Right Leg"].BrickColor)
  189.     lastcolor.Name = "lastcolor"
  190.     character["Right Leg"].BrickColor = BrickColor.Black()
  191.     --
  192.     local lastcolor = Instance.new("StringValue", character.Head)
  193.     lastcolor.Value = tostring(character.Head.BrickColor)
  194.     lastcolor.Name = "lastcolor"
  195.     character.Head.BrickColor = BrickColor.new("Bright yellow")
  196.     ---
  197.     local stud = Instance.new("Decal", character["Right Arm"])
  198.     stud.Texture = "http://www.roblox.com/asset/?id=133864166"
  199.     stud.Face = "Top"
  200.     stud.Name = "PaintballStud"
  201.     ---
  202.     local stud = Instance.new("Decal", character["Left Arm"])
  203.     stud.Texture = "http://www.roblox.com/asset/?id=133864166"
  204.     stud.Face = "Top"
  205.     stud.Name = "PaintballStud"
  206.     --
  207.     local stud = Instance.new("Decal", character["Right Leg"])
  208.     stud.Texture = "http://www.roblox.com/asset/?id=631564059"
  209.     stud.Face = "Bottom"
  210.     stud.Name = "PaintballStud"
  211.     ---
  212.     local stud = Instance.new("Decal", character["Left Leg"])
  213.     stud.Texture = "http://www.roblox.com/asset/?id=631564059"
  214.     stud.Face = "Bottom"
  215.     stud.Name = "PaintballStud"
  216.     ---
  217.     local mask = Instance.new("Part", character)
  218.     mask.Size = Vector3.new(1,1,1)
  219.     mask.CanCollide = false
  220.     mask.Name = "PaintballMask"
  221.     mask:BreakJoints()
  222.     local maskweld = Instance.new("Weld", mask)
  223.     maskweld.Part0 = character.Head
  224.     maskweld.Part1 = mask
  225.     local maskmesh = Instance.new("SpecialMesh", mask)
  226.     maskmesh.MeshId = "http://www.roblox.com/asset/?id=9253927"
  227.     maskmesh.TextureId = "http://www.roblox.com/asset/?id=9253896"
  228.     --
  229.     local humanoidrootpart = Instance.new("Weld", owner.Character.HumanoidRootPart)
  230.     humanoidrootpart.Part0 = owner.Character.HumanoidRootPart
  231.     humanoidrootpart.Part1 = owner.Character.Torso
  232.     humanoidrootpart.Name = "HumanoidRootPartWeldpaintb"
  233.     humanoidrootpart.C0 = CFrame.fromEulerAnglesXYZ(0,-math.pi/4,0)
  234.     local leftarm = Instance.new("Weld", owner.Character.Torso)
  235.     leftarm.Part0 = owner.Character.Torso
  236.     leftarm.Part1 = owner.Character["Left Arm"]
  237.     leftarm.C0 = CFrame.new(-1.5,0.5,0) * CFrame.fromEulerAnglesXYZ(math.pi/2,0,math.pi/4) * CFrame.new(0,-1,0)
  238.     leftarm.Name = "LeftArmWeldpaintb"
  239.     local rightarm = Instance.new("Weld", owner.Character.Torso)
  240.     rightarm.Part0 = owner.Character.Torso
  241.     rightarm.Part1 = owner.Character["Right Arm"]
  242.     rightarm.C0 = CFrame.new(1.5,0.5,0) * CFrame.fromEulerAnglesXYZ(math.pi/2,0,-math.pi/4) * CFrame.new(0,-1,0)
  243.     rightarm.Name = "RightArmWeldpaintb"
  244.     local head = Instance.new("Weld", owner.Character.Torso)
  245.     head.Part0 = owner.Character.Torso
  246.     head.Part1 = owner.Character.Head
  247.     head.C0 = CFrame.new(0,1.5,0) * CFrame.fromEulerAnglesXYZ(0,math.pi/4,0)
  248.     head.Name = "HeadWeldpaintb"
  249. end)
  250. tool.Unequipped:connect(function()
  251.     if character.Torso:findFirstChild("PaintballBlockMesh") then
  252.         character.Torso:findFirstChild("PaintballBlockMesh"):destroy()
  253.     end
  254.     if character.Torso:findFirstChild("LeftArmWeldpaintb") then
  255.         character.Torso:findFirstChild("LeftArmWeldpaintb"):destroy()
  256.     end
  257.     if character.Torso:findFirstChild("RightArmWeldpaintb") then
  258.         character.Torso:findFirstChild("RightArmWeldpaintb"):destroy()
  259.     end
  260.     if character.Torso:findFirstChild("HeadWeldpaintb") then
  261.         character.Torso:findFirstChild("HeadWeldpaintb"):destroy()
  262.     end
  263.     if character:findFirstChild("HumanoidRootPart") then
  264.         if character.HumanoidRootPart:findFirstChild("HumanoidRootPartWeldpaintb") then
  265.             character.HumanoidRootPart:findFirstChild("HumanoidRootPartWeldpaintb"):destroy()
  266.         end
  267.     end
  268.     if character:findFirstChild("PaintballMask") then
  269.         character:findFirstChild("PaintballMask"):destroy()
  270.     end
  271.     if character:findFirstChildOfClass("Pants") then
  272.         character:findFirstChildOfClass("Pants").PantsTemplate = character:findFirstChildOfClass("Pants").lastid.Value
  273.     end
  274.     if character:findFirstChildOfClass("Shirt") then
  275.         character:findFirstChildOfClass("Shirt").ShirtTemplate = character:findFirstChildOfClass("Shirt").lastid.Value
  276.     end
  277.     for i,v in pairs(character:GetChildren()) do
  278.         if v.ClassName == "Accessory" or v.ClassName == "Hat" then
  279.             if v:findFirstChild("Handle") then
  280.                 v:findFirstChild("Handle").Transparency = 0
  281.             end
  282.         end
  283.     end
  284.     for i,v in pairs(character:GetDescendants()) do
  285.         if v.Name == "lastcolor" then
  286.             v.Parent.BrickColor = BrickColor.new(v.Value)
  287.             v:destroy()
  288.         end
  289.         if v.Name == "PaintballStud" then
  290.             v:destroy()
  291.         end
  292.     end
  293. end)
  294. end))
  295. for i,v in pairs(mas:GetChildren()) do
  296.     v.Parent = owner.Character
  297.     pcall(function() v:MakeJoints() end)
  298. end
  299. mas:Destroy()
  300. for i,v in pairs(cors) do
  301.     spawn(function()
  302.         pcall(v)
  303.     end)
  304. end
  305. NLS([[
  306. --By Rufus14
  307. players = game:GetService("Players")
  308. runservice = game:GetService("RunService")
  309. owner = players.LocalPlayer
  310. character = owner.Character
  311. mouse = owner:GetMouse()
  312. tool = script.Parent
  313. handle = tool.Handle
  314. remote = tool:WaitForChild("paintball")
  315. equipped = false
  316. --
  317. tool.Activated:connect(function()
  318.     local playerhumanoid = character:findFirstChildOfClass("Humanoid")
  319.     remote:FireServer("shoot", playerhumanoid.TargetPoint)
  320. end)
  321. --
  322. tool.Equipped:connect(function()
  323.     equipped = true
  324.     owner = players.LocalPlayer
  325.     character = owner.Character
  326.     local playerhumanoid = character:findFirstChildOfClass("Humanoid")
  327.     local rootpart = character:findFirstChild("HumanoidRootPart")
  328.     playerhumanoid.AutoRotate = false
  329.     coroutine.wrap(function()
  330.         while equipped and runservice.RenderStepped:wait() do
  331.             if rootpart then
  332.                 rootpart.CFrame = rootpart.CFrame:lerp(CFrame.new(rootpart.Position, Vector3.new(mouse.Hit.p.x,rootpart.Position.y,mouse.Hit.p.z)),0.4)
  333.             end
  334.         end
  335.     end)()
  336. end)
  337. tool.Unequipped:connect(function()
  338.     local playerhumanoid = character:findFirstChildOfClass("Humanoid")
  339.     playerhumanoid.AutoRotate = true
  340.     equipped = false
  341. end)
  342. ]], Tool0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement