Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Converted with ttyyuu12345's model to script plugin v4
- function sandbox(var,func)
- local env = getfenv(func)
- local newenv = setmetatable({},{
- __index = function(self,k)
- if k=="script" then
- return var
- else
- return env[k]
- end
- end,
- })
- setfenv(func,newenv)
- return func
- end
- cors = {}
- mas = Instance.new("Model",game:GetService("Lighting"))
- Tool0 = Instance.new("Tool")
- Part1 = Instance.new("Part")
- Fire2 = Instance.new("Fire")
- Sound3 = Instance.new("Sound")
- LocalScript4 = Instance.new("LocalScript")
- Script5 = Instance.new("Script")
- Script6 = Instance.new("Script")
- Tool0.Name = "Fireball"
- Tool0.Parent = mas
- Tool0.TextureId = "http://www.roblox.com/asset/?id=25561260"
- Part1.Name = "Handle"
- Part1.Parent = Tool0
- Part1.CFrame = CFrame.new(-4, 4.5, 9, 1, 0, 0, 0, 1, 0, 0, 0, 1)
- Part1.Position = Vector3.new(-4, 4.5, 9)
- Part1.Transparency = 1
- Part1.Size = Vector3.new(1, 1, 1)
- Part1.BottomSurface = Enum.SurfaceType.Smooth
- Part1.TopSurface = Enum.SurfaceType.Smooth
- Part1.FormFactor = Enum.FormFactor.Symmetric
- Part1.formFactor = Enum.FormFactor.Symmetric
- Part1.Shape = Enum.PartType.Ball
- Fire2.Parent = Part1
- Fire2.Color = Color3.new(1, 0.505882, 0)
- Fire2.Size = 2
- Fire2.Heat = 0
- Fire2.SecondaryColor = Color3.new(1, 0, 0)
- Fire2.size = 2
- Sound3.Name = "SlingshotSound"
- Sound3.Parent = Part1
- Sound3.Pitch = 4
- Sound3.PlaybackSpeed = 4
- Sound3.SoundId = "http://www.roblox.com/asset/?id=30624426"
- Sound3.Volume = 0.10000000149012
- LocalScript4.Name = "Local Gui"
- LocalScript4.Parent = Tool0
- LocalScript4.LinkedSource = "http://www.roblox.com/asset/?id=1014650"
- Script5.Name = "Slingshot"
- Script5.Parent = Tool0
- table.insert(cors,sandbox(Script5,function()
- Tool = script.Parent
- VELOCITY = 85 -- constant
- local Pellet = Instance.new("Part")
- Pellet.Locked = true
- Pellet.BackSurface = 0
- Pellet.BottomSurface = 0
- Pellet.FrontSurface = 0
- Pellet.LeftSurface = 0
- Pellet.RightSurface = 0
- Pellet.TopSurface = 0
- Pellet.Shape = 0
- Pellet.Size = Vector3.new(1,1,1)
- Pellet.Transparency = (1)
- script.Parent.PelletScript:clone().Parent = Pellet
- Fire = script.Parent.Handle.Fire:Clone()
- Fire.Size = Fire.Size*2.5
- Fire.Parent = Pellet
- SST = Instance.new("Sound")
- SST.Pitch = 6
- SST.Volume = 0.1
- SST.SoundId = "http://www.roblox.com/asset/?id=30624426"
- SST.Parent = Pellet
- SST.Name = "SST"
- Foosh = Instance.new("Sound")
- Foosh.Pitch = 2
- Foosh.Volume = 0.25
- Foosh.SoundId = "http://www.roblox.com/asset/?id=30624426"
- Foosh.Parent = Pellet
- Foosh.Name = "Foosh"
- function fire(mouse_pos)
- Tool.Handle.SlingshotSound:play()
- -- find player's head pos
- local vCharacter = Tool.Parent
- local vPlayer = game.Players:playerFromCharacter(vCharacter)
- local head = vCharacter:findFirstChild("Head")
- if head == nil then return end
- local dir = mouse_pos - head.Position
- dir = computeDirection(dir)
- local launch = head.Position + 5 * dir
- local delta = mouse_pos - launch
- local dy = delta.y
- local new_delta = Vector3.new(delta.x, 0, delta.z)
- delta = new_delta
- local dx = delta.magnitude
- local unit_delta = delta.unit
- -- acceleration due to gravity in RBX units
- local g = (-9.81 * 20)
- local theta = computeLaunchAngle( dx, dy, g)
- local vy = math.sin(theta)
- local xz = math.cos(theta)
- local vx = unit_delta.x * xz
- local vz = unit_delta.z * xz
- local missile = Pellet:clone()
- missile.Position = launch
- missile.Velocity = Vector3.new(vx,vy,vz) * VELOCITY
- missile.PelletScript.Disabled = false
- local creator_tag = Instance.new("ObjectValue")
- creator_tag.Value = vPlayer
- creator_tag.Name = "creator"
- creator_tag.Parent = missile
- missile.Parent = game.Workspace
- end
- function computeLaunchAngle(dx,dy,grav)
- -- arcane
- -- http://en.wikipedia.org/wiki/Trajectory_of_a_projectile
- local g = math.abs(grav)
- local inRoot = (VELOCITY*VELOCITY*VELOCITY*VELOCITY) - (g * ((g*dx*dx) + (2*dy*VELOCITY*VELOCITY)))
- if inRoot <= 0 then
- return .25 * math.pi
- end
- local root = math.sqrt(inRoot)
- local inATan1 = ((VELOCITY*VELOCITY) + root) / (g*dx)
- local inATan2 = ((VELOCITY*VELOCITY) - root) / (g*dx)
- local answer1 = math.atan(inATan1)
- local answer2 = math.atan(inATan2)
- if answer1 < answer2 then return answer1 end
- return answer2
- end
- function computeDirection(vec)
- local lenSquared = vec.magnitude * vec.magnitude
- local invSqrt = 1 / math.sqrt(lenSquared)
- return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)
- end
- Tool.Enabled = true
- function onActivated()
- if not Tool.Enabled then
- return
- end
- Tool.Enabled = false
- local character = Tool.Parent;
- local humanoid = character.Humanoid
- if humanoid == nil then
- print("Humanoid not found")
- return
- end
- local targetPos = humanoid.TargetPoint
- fire(targetPos)
- wait(.2)
- Tool.Enabled = true
- end
- script.Parent.Activated:connect(onActivated)
- end))
- Script6.Name = "PelletScript"
- Script6.Parent = Tool0
- table.insert(cors,sandbox(Script6,function()
- local debris = game:service("Debris")
- pellet = script.Parent
- damage = 8
- function onTouched(hit)
- pellet.SST:Play()
- humanoid = hit.Parent:findFirstChild("Humanoid")
- if humanoid~=nil then
- pellet.Foosh:Play()
- tagHumanoid(humanoid)
- humanoid:TakeDamage(damage)
- Flame = pellet.Fire:Clone()
- Flame.Heat = 15
- Flame.Parent = humanoid.Parent.Torso
- if humanoid.Parent.Torso == nil then
- print("oops")
- end
- debris:AddItem(Flame, 2.5)
- else
- damage = damage / 2
- if damage < 1 then
- connection:disconnect()
- pellet.Parent = nil
- end
- end
- end
- function tagHumanoid(humanoid)
- -- todo: make tag expire
- local tag = pellet:findFirstChild("creator")
- if tag ~= nil then
- -- kill all other tags
- while(humanoid:findFirstChild("creator") ~= nil) do
- humanoid:findFirstChild("creator").Parent = nil
- end
- local new_tag = tag:clone()
- new_tag.Parent = humanoid
- debris:AddItem(new_tag, 1)
- end
- end
- connection = pellet.Touched:connect(onTouched)
- r = game:service("RunService")
- t, s = r.Stepped:wait()
- d = t + 2.0 - s
- while t < d do
- t = r.Stepped:wait()
- end
- pellet.Parent = nil
- end))
- Script6.Disabled = true
- for i,v in pairs(mas:GetChildren()) do
- v.Parent = game:GetService("Players").LocalPlayer.Character
- pcall(function() v:MakeJoints() end)
- end
- mas:Destroy()
- for i,v in pairs(cors) do
- spawn(function()
- pcall(v)
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement