Advertisement
HenloMyDude

paintball with teams and fair damage

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