Advertisement
cat568

Untitled

Jun 19th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.35 KB | None | 0 0
  1.  
  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. Fire2 = Instance.new("Fire")
  22. Sound3 = Instance.new("Sound")
  23. LocalScript4 = Instance.new("LocalScript")
  24. Script5 = Instance.new("Script")
  25. Script6 = Instance.new("Script")
  26. Tool0.Name = "Fireball"
  27. Tool0.Parent = mas
  28. Tool0.TextureId = "http://www.roblox.com/asset/?id=25561260"
  29. Part1.Name = "Handle"
  30. Part1.Parent = Tool0
  31. Part1.CFrame = CFrame.new(-4, 4.5, 9, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  32. Part1.Position = Vector3.new(-4, 4.5, 9)
  33. Part1.Transparency = 1
  34. Part1.Size = Vector3.new(1, 1, 1)
  35. Part1.BottomSurface = Enum.SurfaceType.Smooth
  36. Part1.TopSurface = Enum.SurfaceType.Smooth
  37. Part1.FormFactor = Enum.FormFactor.Symmetric
  38. Part1.formFactor = Enum.FormFactor.Symmetric
  39. Part1.Shape = Enum.PartType.Ball
  40. Fire2.Parent = Part1
  41. Fire2.Color = Color3.new(1, 0.505882, 0)
  42. Fire2.Size = 2
  43. Fire2.Heat = 0
  44. Fire2.SecondaryColor = Color3.new(1, 0, 0)
  45. Fire2.size = 2
  46. Sound3.Name = "SlingshotSound"
  47. Sound3.Parent = Part1
  48. Sound3.Pitch = 4
  49. Sound3.PlaybackSpeed = 4
  50. Sound3.SoundId = "http://www.roblox.com/asset/?id=30624426"
  51. Sound3.Volume = 0.10000000149012
  52. LocalScript4.Name = "Local Gui"
  53. LocalScript4.Parent = Tool0
  54. LocalScript4.LinkedSource = "http://www.roblox.com/asset/?id=1014650"
  55. Script5.Name = "Slingshot"
  56. Script5.Parent = Tool0
  57. table.insert(cors,sandbox(Script5,function()
  58. Tool = script.Parent
  59. VELOCITY = 85 -- constant
  60.  
  61. local Pellet = Instance.new("Part")
  62. Pellet.Locked = true
  63. Pellet.BackSurface = 0
  64. Pellet.BottomSurface = 0
  65. Pellet.FrontSurface = 0
  66. Pellet.LeftSurface = 0
  67. Pellet.RightSurface = 0
  68. Pellet.TopSurface = 0
  69. Pellet.Shape = 0
  70. Pellet.Size = Vector3.new(1,1,1)
  71. Pellet.Transparency = (1)
  72. script.Parent.PelletScript:clone().Parent = Pellet
  73.  
  74. Fire = script.Parent.Handle.Fire:Clone()
  75. Fire.Size = Fire.Size*2.5
  76. Fire.Parent = Pellet
  77.  
  78. SST = Instance.new("Sound")
  79. SST.Pitch = 6
  80. SST.Volume = 0.1
  81. SST.SoundId = "http://www.roblox.com/asset/?id=30624426"
  82. SST.Parent = Pellet
  83. SST.Name = "SST"
  84.  
  85. Foosh = Instance.new("Sound")
  86. Foosh.Pitch = 2
  87. Foosh.Volume = 0.25
  88. Foosh.SoundId = "http://www.roblox.com/asset/?id=30624426"
  89. Foosh.Parent = Pellet
  90. Foosh.Name = "Foosh"
  91.  
  92. function fire(mouse_pos)
  93.  
  94.  
  95. Tool.Handle.SlingshotSound:play()
  96.  
  97. -- find player's head pos
  98.  
  99. local vCharacter = Tool.Parent
  100. local vPlayer = game.Players:playerFromCharacter(vCharacter)
  101.  
  102. local head = vCharacter:findFirstChild("Head")
  103. if head == nil then return end
  104.  
  105. local dir = mouse_pos - head.Position
  106. dir = computeDirection(dir)
  107.  
  108. local launch = head.Position + 5 * dir
  109.  
  110. local delta = mouse_pos - launch
  111.  
  112. local dy = delta.y
  113.  
  114. local new_delta = Vector3.new(delta.x, 0, delta.z)
  115. delta = new_delta
  116.  
  117. local dx = delta.magnitude
  118. local unit_delta = delta.unit
  119.  
  120. -- acceleration due to gravity in RBX units
  121. local g = (-9.81 * 20)
  122.  
  123. local theta = computeLaunchAngle( dx, dy, g)
  124.  
  125. local vy = math.sin(theta)
  126. local xz = math.cos(theta)
  127. local vx = unit_delta.x * xz
  128. local vz = unit_delta.z * xz
  129.  
  130.  
  131. local missile = Pellet:clone()
  132.  
  133.  
  134.  
  135.  
  136. missile.Position = launch
  137. missile.Velocity = Vector3.new(vx,vy,vz) * VELOCITY
  138.  
  139. missile.PelletScript.Disabled = false
  140.  
  141. local creator_tag = Instance.new("ObjectValue")
  142. creator_tag.Value = vPlayer
  143. creator_tag.Name = "creator"
  144. creator_tag.Parent = missile
  145.  
  146. missile.Parent = game.Workspace
  147.  
  148. end
  149.  
  150.  
  151. function computeLaunchAngle(dx,dy,grav)
  152. -- arcane
  153. -- http://en.wikipedia.org/wiki/Trajectory_of_a_projectile
  154.  
  155. local g = math.abs(grav)
  156. local inRoot = (VELOCITY*VELOCITY*VELOCITY*VELOCITY) - (g * ((g*dx*dx) + (2*dy*VELOCITY*VELOCITY)))
  157. if inRoot <= 0 then
  158. return .25 * math.pi
  159. end
  160. local root = math.sqrt(inRoot)
  161. local inATan1 = ((VELOCITY*VELOCITY) + root) / (g*dx)
  162.  
  163. local inATan2 = ((VELOCITY*VELOCITY) - root) / (g*dx)
  164. local answer1 = math.atan(inATan1)
  165. local answer2 = math.atan(inATan2)
  166. if answer1 < answer2 then return answer1 end
  167. return answer2
  168. end
  169.  
  170. function computeDirection(vec)
  171. local lenSquared = vec.magnitude * vec.magnitude
  172. local invSqrt = 1 / math.sqrt(lenSquared)
  173. return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)
  174. end
  175.  
  176.  
  177.  
  178.  
  179. Tool.Enabled = true
  180. function onActivated()
  181.  
  182. if not Tool.Enabled then
  183. return
  184. end
  185.  
  186. Tool.Enabled = false
  187.  
  188. local character = Tool.Parent;
  189. local humanoid = character.Humanoid
  190. if humanoid == nil then
  191. print("Humanoid not found")
  192. return
  193. end
  194.  
  195. local targetPos = humanoid.TargetPoint
  196.  
  197. fire(targetPos)
  198.  
  199. wait(.2)
  200.  
  201. Tool.Enabled = true
  202. end
  203.  
  204. script.Parent.Activated:connect(onActivated)
  205.  
  206.  
  207.  
  208. end))
  209. Script6.Name = "PelletScript"
  210. Script6.Parent = Tool0
  211. table.insert(cors,sandbox(Script6,function()
  212. local debris = game:service("Debris")
  213. pellet = script.Parent
  214. damage = 8
  215.  
  216. function onTouched(hit)
  217. pellet.SST:Play()
  218. humanoid = hit.Parent:findFirstChild("Humanoid")
  219. if humanoid~=nil then
  220. pellet.Foosh:Play()
  221. tagHumanoid(humanoid)
  222. humanoid:TakeDamage(damage)
  223. Flame = pellet.Fire:Clone()
  224. Flame.Heat = 15
  225. Flame.Parent = humanoid.Parent.Torso
  226. if humanoid.Parent.Torso == nil then
  227. print("oops")
  228. end
  229. debris:AddItem(Flame, 2.5)
  230. else
  231. damage = damage / 2
  232. if damage < 1 then
  233. connection:disconnect()
  234. pellet.Parent = nil
  235. end
  236. end
  237. end
  238.  
  239. function tagHumanoid(humanoid)
  240. -- todo: make tag expire
  241. local tag = pellet:findFirstChild("creator")
  242. if tag ~= nil then
  243. -- kill all other tags
  244. while(humanoid:findFirstChild("creator") ~= nil) do
  245. humanoid:findFirstChild("creator").Parent = nil
  246. end
  247.  
  248. local new_tag = tag:clone()
  249. new_tag.Parent = humanoid
  250. debris:AddItem(new_tag, 1)
  251. end
  252. end
  253.  
  254. connection = pellet.Touched:connect(onTouched)
  255.  
  256. r = game:service("RunService")
  257. t, s = r.Stepped:wait()
  258. d = t + 2.0 - s
  259. while t < d do
  260. t = r.Stepped:wait()
  261. end
  262.  
  263. pellet.Parent = nil
  264. end))
  265. Script6.Disabled = true
  266. for i,v in pairs(mas:GetChildren()) do
  267. v.Parent = game:GetService("Players").LocalPlayer.Character
  268. pcall(function() v:MakeJoints() end)
  269. end
  270. mas:Destroy()
  271. for i,v in pairs(cors) do
  272. spawn(function()
  273. pcall(v)
  274. end)
  275. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement