Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if game:GetService("RunService"):IsClient() then error("Please run as a server script. Use h/ instead of hl/.") end
- print("FE Compatibility: by WaverlyCole & Mokiros")
- InternalData = {}
- do
- script.Parent = owner.Character
- local Event = Instance.new("RemoteEvent")
- Event.Name = "UserInput"
- local function NewFakeEvent()
- local Fake = {fakeEvent=true,Connect=function(self,Func)self.Function=Func end}Fake.connect = Fake.Connect
- return Fake
- end
- local Mouse = {Target=nil,Hit=CFrame.new(),KeyUp=NewFakeEvent(),KeyDown=NewFakeEvent(),Button1Up=NewFakeEvent(),Button1Down=NewFakeEvent()}
- local UserInputService = {InputBegan=NewFakeEvent(),InputEnded=NewFakeEvent()}
- local ContextActionService = {Actions={},BindAction = function(self,actionName,Func,touch,...)
- self.Actions[actionName] = Func and {Name=actionName,Function=Func,Keys={...}} or nil
- end};ContextActionService.UnBindAction = ContextActionService.BindAction
- local function TriggerEvent(self,Event,...)
- local Trigger = Mouse[Event]
- if Trigger and Trigger.fakeEvent and Trigger.Function then
- Trigger.Function(...)
- end
- end
- Mouse.TrigEvent = TriggerEvent
- UserInputService.TrigEvent = TriggerEvent
- Event.OnServerEvent:Connect(function(FiredBy,Input)
- if FiredBy.Name ~= owner.Name then end
- if Input.MouseEvent then
- Mouse.Target = Input.Target
- Mouse.Hit = Input.Hit
- else
- local Begin = Input.UserInputState == Enum.UserInputState.Begin
- if Input.UserInputType == Enum.UserInputType.MouseButton1 then
- return Mouse:TrigEvent(Begin and "Button1Down" or "Button1Up")
- end
- for _,Action in pairs(ContextActionService.Actions) do
- for _,Key in pairs(Action.Keys) do
- if Key==Input.KeyCode then
- Action.Function(Action.Name,Input.UserInputState,Input)
- end
- end
- end
- Mouse:TrigEvent(Begin and "KeyDown" or "KeyUp",Input.KeyCode.Name:lower())
- UserInputService:TrigEvent(Begin and "InputBegan" or "InputEnded",Input,false)
- end
- end)
- InternalData["Mouse"] = Mouse
- InternalData["ContextActionService"] = ContextActionService
- InternalData["UserInputService"] = UserInputService
- Event.Parent = NLS([[
- local Player = owner
- local Event = script:WaitForChild("UserInput")
- local UserInputService = game:GetService("UserInputService")
- local Mouse = Player:GetMouse()
- local Input = function(Input,gameProcessedEvent)
- if gameProcessedEvent then return end
- Event:FireServer({KeyCode=Input.KeyCode,UserInputType=Input.UserInputType,UserInputState=Input.UserInputState})
- end
- UserInputService.InputBegan:Connect(Input)
- UserInputService.InputEnded:Connect(Input)
- local Hit,Target
- while wait(1/30) do
- if Hit ~= Mouse.Hit or Target ~= Mouse.Target then
- Hit,Target = Mouse.Hit,Mouse.Target
- Event:FireServer({["MouseEvent"]=true,["Target"]=Target,["Hit"]=Hit})
- end
- end
- ]],owner.Character)
- end
- RealGame = game;game = setmetatable({},{
- __index = function (self,Index)
- local Sandbox = function (Thing)
- if Thing:IsA("Player") then
- local RealPlayer = Thing
- return setmetatable({},{
- __index = function (self,Index)
- local Type = type(RealPlayer[Index])
- if Type == "function" then
- if Index:lower() == "getmouse" or Index:lower() == "mouse" then
- return function (self)
- return InternalData["Mouse"]
- end
- end
- return function (self,...)
- return RealPlayer[Index](RealPlayer,...)
- end
- else
- return RealPlayer[Index]
- end
- end;
- __tostring = function(self)
- return RealPlayer.Name
- end
- })
- end
- end
- if RealGame[Index] then
- local Type = type(RealGame[Index])
- if Type == "function" then
- if Index:lower() == "getservice" or Index:lower() == "service" then
- return function (self,Service)
- if Service:lower() == "players" then
- return setmetatable({},{
- __index = function (self2,Index2)
- local RealService = RealGame:GetService(Service)
- local Type2 = type(Index2)
- if Type2 == "function" then
- return function (self,...)
- return RealService[Index2](RealService,...)
- end
- else
- if Index2:lower() == "localplayer" then
- return Sandbox(owner)
- end
- return RealService[Index2]
- end
- end;
- __tostring = function(self)
- return RealGame:GetService(Service).Name
- end
- })
- elseif Service:lower() == "contextactionservice" then
- return InternalData["ContextActionService"]
- elseif Service:lower() == "contextactionservice" then
- return InternalData["UserInputService"]
- elseif Service:lower() == "runservice" then
- return setmetatable({},{
- __index = function(self2,Index2)
- local RealService = RealGame:GetService(Service)
- local Type2 = type(Index2)
- if Type2 == "function" then
- return function (self,...)
- return RealService[Index2](RealService,...)
- end
- else
- if Index2:lower() == "bindtorenderstep" then
- return function (self,Name,Priority,Function)
- return RealGame:GetService("RunService").Stepped:Connect(Function)
- end
- end
- if Index2:lower() == "renderstepped" then
- return RealService["Stepped"]
- end
- return RealService[Index2]
- end
- end
- })
- else
- return RealGame:GetService(Service)
- end
- end
- end
- return function (self,...)
- return RealGame[Index](RealGame,...)
- end
- else
- if game:GetService(Index) then
- return game:GetService(Index)
- end
- return RealGame[Index]
- end
- else
- return nil
- end
- end
- });Game = game;owner = game:GetService("Players").LocalPlayer
- 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")
- SpecialMesh2 = Instance.new("SpecialMesh")
- Script3 = Instance.new("Script")
- Sound4 = Instance.new("Sound")
- Sound5 = Instance.new("Sound")
- Script6 = Instance.new("Script")
- LocalScript7 = Instance.new("LocalScript")
- Configuration8 = Instance.new("Configuration")
- NumberValue9 = Instance.new("NumberValue")
- IntValue10 = Instance.new("IntValue")
- NumberValue11 = Instance.new("NumberValue")
- IntValue12 = Instance.new("IntValue")
- IntValue13 = Instance.new("IntValue")
- IntValue14 = Instance.new("IntValue")
- ModuleScript15 = Instance.new("ModuleScript")
- Tool0.Name = "RocketLauncher"
- Tool0.Parent = mas
- Tool0.TextureId = "http://www.roblox.com/asset/?id=90021376"
- Tool0.CanBeDropped = false
- Tool0.Grip = CFrame.new(0.699999988, 0, -0.5, 0, 0, -1, -1, 0, 0, 0, 1, 0)
- Tool0.GripForward = Vector3.new(1, -0, -0)
- Tool0.GripPos = Vector3.new(0.699999988, 0, -0.5)
- Tool0.GripRight = Vector3.new(0, -1, 0)
- Tool0.GripUp = Vector3.new(0, 0, 1)
- Part1.Name = "Handle"
- Part1.Parent = Tool0
- Part1.CFrame = CFrame.new(7.14963484, 0.420024008, -0.560084999, 1, 0, 0, 0, 6.30170107e-05, 1.00000024, 0, -1.00000024, 6.30170107e-05)
- Part1.Orientation = Vector3.new(-90, 0, 0)
- Part1.Position = Vector3.new(7.14963484, 0.420024008, -0.560084999)
- Part1.Rotation = Vector3.new(-90, 0, 0)
- Part1.Size = Vector3.new(4.92000628, 0.740000546, 0.839999795)
- Part1.BottomSurface = Enum.SurfaceType.Smooth
- Part1.TopSurface = Enum.SurfaceType.Smooth
- Part1.FormFactor = Enum.FormFactor.Custom
- Part1.formFactor = Enum.FormFactor.Custom
- SpecialMesh2.Parent = Part1
- SpecialMesh2.MeshId = "rbxasset://fonts/rocketlauncher.mesh"
- SpecialMesh2.Scale = Vector3.new(0.75, 0.75, 0.75)
- SpecialMesh2.TextureId = "rbxasset://textures/rocketlaunchertex.png"
- SpecialMesh2.MeshType = Enum.MeshType.FileMesh
- Script3.Parent = Tool0
- table.insert(cors,sandbox(Script3,function()
- local tool = script.Parent
- local canFire = true
- local gunWeld
- -----------------
- --| Constants |--
- -----------------
- local GRAVITY_ACCELERATION = 196.2
- local RELOAD_TIME = tool.Configurations.ReloadTime.Value -- Seconds until tool can be used again
- local ROCKET_SPEED = tool.Configurations.RocketSpeed.Value -- Speed of the projectile
- local MISSILE_MESH_ID = 'http://www.roblox.com/asset/?id=2251534'
- local MISSILE_MESH_SCALE = Vector3.new(0.35, 0.35, 0.25)
- local ROCKET_PART_SIZE = Vector3.new(1.2, 1.2, 3.27)
- local RocketScript = script:WaitForChild('Rocket')
- local SwooshSound = script:WaitForChild('Swoosh')
- local BoomSound = script:WaitForChild('Boom')
- local attackCooldown = tool.Configurations.AttackCooldown.Value
- local damage = tool.Configurations.Damage.Value
- local reloadTime = tool.Configurations.ReloadTime.Value
- local function createEvent(eventName)
- local event = game.ReplicatedStorage:FindFirstChild(eventName)
- if not event then
- event = Instance.new("RemoteEvent", game.ReplicatedStorage)
- event.Name = eventName
- end
- return event
- end
- local updateEvent = createEvent("ROBLOX_RocketUpdateEvent")
- local equipEvent = createEvent("ROBLOX_RocketEquipEvent")
- local unequipEvent = createEvent("ROBLOX_RocketUnequipEvent")
- local fireEvent = createEvent("ROBLOX_RocketFireEvent")
- updateEvent.OnServerEvent:connect(function(player, neckC0, rshoulderC0)
- local character = player.Character
- local humanoid = character.Humanoid
- if humanoid.Health <= 0 then return end
- if humanoid.RigType == Enum.HumanoidRigType.R6 then
- character.Torso.Neck.C0 = neckC0
- character.Torso:FindFirstChild("Right Shoulder").C0 = rshoulderC0
- gunWeld = character:FindFirstChild("Right Arm"):WaitForChild("RightGrip")
- elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
- character.Head.Neck.C0 = neckC0
- character.RightUpperArm.RightShoulder.C0 = rshoulderC0
- gunWeld = character.RightHand:WaitForChild("RightGrip")
- end
- end)
- equipEvent.OnServerEvent:connect(function(player)
- player.Character.Humanoid.AutoRotate = false
- end)
- unequipEvent.OnServerEvent:connect(function(player)
- player.Character.Humanoid.AutoRotate = true
- end)
- --NOTE: We create the rocket once and then clone it when the player fires
- local Rocket = Instance.new('Part') do
- -- Set up the rocket part
- Rocket.Name = 'Rocket'
- Rocket.FormFactor = Enum.FormFactor.Custom --NOTE: This must be done before changing Size
- Rocket.Size = ROCKET_PART_SIZE
- Rocket.CanCollide = false
- -- Add the mesh
- local mesh = Instance.new('SpecialMesh', Rocket)
- mesh.MeshId = MISSILE_MESH_ID
- mesh.Scale = MISSILE_MESH_SCALE
- -- Add fire
- local fire = Instance.new('Fire', Rocket)
- fire.Heat = 5
- fire.Size = 2
- -- Add a force to counteract gravity
- local bodyForce = Instance.new('BodyForce', Rocket)
- bodyForce.Name = 'Antigravity'
- bodyForce.force = Vector3.new(0, Rocket:GetMass() * GRAVITY_ACCELERATION, 0)
- -- Clone the sounds and set Boom to PlayOnRemove
- local swooshSoundClone = SwooshSound:Clone()
- swooshSoundClone.Parent = Rocket
- local boomSoundClone = BoomSound:Clone()
- boomSoundClone.PlayOnRemove = true
- boomSoundClone.Parent = Rocket
- -- Finally, clone the rocket script and enable it
- -- local rocketScriptClone = RocketScript:Clone()
- -- rocketScriptClone.Parent = Rocket
- -- rocketScriptClone.Disabled = false
- end
- fireEvent.OnServerEvent:connect(function(player, target)
- if canFire and player.Character == tool.Parent then
- canFire = false
- -- Create a clone of Rocket and set its color
- local rocketClone = Rocket:Clone()
- --game.Debris:AddItem(rocketClone, 30)
- rocketClone.BrickColor = player.TeamColor
- rocketClone.Touched:connect(function(hit)
- if hit and hit.Parent and hit.Parent ~= player.Character and hit.Parent ~= tool then
- local explosion = Instance.new("Explosion", game.Workspace)
- explosion.Position = rocketClone.Position
- rocketClone:Destroy()
- end
- end)
- spawn(function()
- wait(30)
- if rocketClone then rocketClone:Destroy() end
- end)
- -- Position the rocket clone and launch!
- local spawnPosition = (tool.Handle.CFrame * CFrame.new(2, 0, 0)).p
- rocketClone.CFrame = CFrame.new(spawnPosition, target) --NOTE: This must be done before assigning Parent
- rocketClone.Velocity = rocketClone.CFrame.lookVector * ROCKET_SPEED --NOTE: This should be done before assigning Parent
- rocketClone.Parent = game.Workspace
- -- Attach creator tags to the rocket early on
- local creatorTag = Instance.new('ObjectValue', rocketClone)
- creatorTag.Value = player
- creatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website stats
- local iconTag = Instance.new('StringValue', creatorTag)
- iconTag.Value = tool.TextureId
- iconTag.Name = 'icon'
- delay(attackCooldown, function()
- canFire = true
- end)
- end
- end)
- end))
- Sound4.Name = "Boom"
- Sound4.Parent = Script3
- Sound4.SoundId = "rbxasset://sounds/collide.wav"
- Sound4.Volume = 1
- Sound5.Name = "Swoosh"
- Sound5.Parent = Script3
- Sound5.Looped = true
- Sound5.SoundId = "rbxasset://sounds/Rocket whoosh 01.wav"
- Sound5.Volume = 0.69999998807907
- Script6.Name = "Rocket"
- Script6.Parent = Script3
- table.insert(cors,sandbox(Script6,function()
- -----------------
- --| Constants |--
- -----------------
- local BLAST_RADIUS = script.Parent.Parent.Configurations.BlastRadius.Value -- Blast radius of the explosion
- local BLAST_DAMAGE = script.Parent.Parent.Configurations.Damage.Value -- Amount of damage done to players
- local BLAST_FORCE = script.Parent.Parent.Configurations.BlastForce.Value -- Amount of force applied to parts
- local IGNORE_LIST = {rocket = 1, handle = 1, effect = 1, water = 1} -- Rocket will fly through things named these
- --NOTE: Keys must be lowercase, values must evaluate to true
- -----------------
- --| Variables |--
- -----------------
- local DebrisService = game:GetService('Debris')
- local PlayersService = game:GetService('Players')
- local Rocket = script.Parent
- local CreatorTag = Rocket:WaitForChild('creator', 60)
- local SwooshSound = Rocket:WaitForChild('Swoosh', 60)
- -----------------
- --| Functions |--
- -----------------
- -- Removes any old creator tags and applies a new one to the target
- local function ApplyTags(target)
- while target:FindFirstChild('creator') do
- target.creator:Destroy()
- end
- local creatorTagClone = CreatorTag:Clone()
- DebrisService:AddItem(creatorTagClone, 1.5)
- creatorTagClone.Parent = target
- end
- -- Returns the ancestor that contains a Humanoid, if it exists
- local function FindCharacterAncestor(subject)
- if subject and subject ~= game.Workspace then
- local humanoid = subject:FindFirstChild('Humanoid')
- if humanoid then
- return subject, humanoid
- else
- return FindCharacterAncestor(subject.Parent)
- end
- end
- return nil
- end
- -- Customized explosive effect that doesn't affect teammates and only breaks joints on dead parts
- local function OnExplosionHit(hitPart, hitDistance, blastCenter)
- if hitPart and hitDistance then
- local character, humanoid = FindCharacterAncestor(hitPart.Parent)
- if character then
- local myPlayer = CreatorTag.Value
- if myPlayer and not myPlayer.Neutral then -- Ignore friendlies caught in the blast
- local player = PlayersService:GetPlayerFromCharacter(character)
- if player and player ~= myPlayer and player.TeamColor == Rocket.BrickColor then
- return
- end
- end
- end
- if humanoid and humanoid.Health > 0 then -- Humanoids are tagged and damaged
- if hitPart.Name == 'Torso' then
- ApplyTags(humanoid)
- humanoid:TakeDamage(BLAST_DAMAGE)
- end
- else -- Loose parts and dead parts are blasted
- if hitPart.Name ~= 'Handle' then
- hitPart:BreakJoints()
- local blastForce = Instance.new('BodyForce', hitPart) --NOTE: We will multiply by mass so bigger parts get blasted more
- blastForce.force = (hitPart.Position - blastCenter).unit * BLAST_FORCE * hitPart:GetMass()
- DebrisService:AddItem(blastForce, 0.1)
- end
- end
- end
- end
- local function OnTouched(otherPart)
- if Rocket and otherPart then
- -- Fly through anything in the ignore list
- if IGNORE_LIST[string.lower(otherPart.Name)] then
- return
- end
- local myPlayer = CreatorTag.Value
- if myPlayer then
- -- Fly through the creator
- if myPlayer.Character and myPlayer.Character:IsAncestorOf(otherPart) then
- return
- end
- -- Fly through friendlies
- if not myPlayer.Neutral then
- local character = FindCharacterAncestor(otherPart.Parent)
- local player = PlayersService:GetPlayerFromCharacter(character)
- if player and player ~= myPlayer and player.TeamColor == Rocket.BrickColor then
- return
- end
- end
- end
- -- Fly through terrain water
- if otherPart == game.Workspace.Terrain then
- --NOTE: If the rocket is large, then the simplifications made here will cause it to fly through terrain in some cases
- local frontOfRocket = Rocket.Position + (Rocket.CFrame.lookVector * (Rocket.Size.Z / 2))
- local cellLocation = game.Workspace.Terrain:WorldToCellPreferSolid(frontOfRocket)
- local cellMaterial = game.Workspace.Terrain:GetCell(cellLocation.X, cellLocation.Y, cellLocation.Z)
- if cellMaterial == Enum.CellMaterial.Water or cellMaterial == Enum.CellMaterial.Empty then
- return
- end
- end
- -- Create the explosion
- local explosion = Instance.new('Explosion')
- explosion.BlastPressure = 0 -- Completely safe explosion
- explosion.BlastRadius = BLAST_RADIUS
- explosion.ExplosionType = Enum.ExplosionType.NoCraters
- explosion.Position = Rocket.Position
- explosion.Parent = game.Workspace
- -- Connect custom logic for the explosion
- explosion.Hit:connect(function(hitPart, hitDistance) OnExplosionHit(hitPart, hitDistance, explosion.Position) end)
- -- Move this script and the creator tag (so our custom logic can execute), then destroy the rocket
- script.Parent = explosion
- CreatorTag.Parent = script
- Rocket:Destroy()
- end
- end
- --------------------
- --| Script Logic |--
- --------------------
- SwooshSound:Play()
- Rocket.Touched:connect(OnTouched)
- end))
- LocalScript7.Parent = Tool0
- table.insert(cors,sandbox(LocalScript7,function()
- -- Variables for services
- local render = game:GetService("RunService").RenderStepped
- local contextActionService = game:GetService("ContextActionService")
- local userInputService = game:GetService("UserInputService")
- local player = game.Players.LocalPlayer
- local mouse = player:GetMouse()
- local Tool = script.Parent
- -- Variables for Module Scripts
- local screenSpace = require(Tool:WaitForChild("ScreenSpace"))
- local connection
- local neck, shoulder, oldNeckC0, oldShoulderC0
- local mobileShouldTrack = true
- -- Thourough check to see if a character is sitting
- local function amISitting(character)
- return character.Humanoid.SeatPart ~= nil
- end
- -- Function to call on renderstepped. Orients the character so it is facing towards
- -- the player mouse's position in world space. If character is sitting then the torso
- -- should not track
- local function frame(mousePosition)
- -- Special mobile consideration. We don't want to track if the user was touching a ui
- -- element such as the movement controls. Just return out of function if so to make sure
- -- character doesn't track
- if not mobileShouldTrack then return end
- --This math is completely wrong with R15. We're better off just not doing it at all
- if player.Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
- return
- end
- -- Make sure character isn't swiming. If the character is swimming the following code will
- -- not work well; the character will not swim correctly. Besides, who shoots underwater?
- if player.Character.Humanoid:GetState() ~= Enum.HumanoidStateType.Swimming then
- local torso = player.Character.HumanoidRootPart
- local head = player.Character.Head
- local toMouse = (mousePosition - head.Position).unit
- local angle = math.acos(toMouse:Dot(Vector3.new(0,1,0)))
- local neckAngle = angle
- -- Limit how much the head can tilt down. Too far and the head looks unnatural
- if math.deg(neckAngle) > 110 then
- neckAngle = math.rad(110)
- end
- neck.C0 = CFrame.new(0,1,0) * CFrame.Angles(math.pi - neckAngle,math.pi,0)
- -- Calculate horizontal rotation
- local arm do
- arm = player.Character:FindFirstChild("Right Arm") or
- player.Character:FindFirstChild("RightUpperArm")
- end
- local fromArmPos = torso.Position + torso.CFrame:vectorToWorldSpace(Vector3.new(
- torso.Size.X/2 + arm.Size.X/2, torso.Size.Y/2 - arm.Size.Z/2, 0))
- local toMouseArm = ((mousePosition - fromArmPos) * Vector3.new(1,0,1)).unit
- local look = (torso.CFrame.lookVector * Vector3.new(1,0,1)).unit
- local lateralAngle = math.acos(toMouseArm:Dot(look))
- -- Check for rogue math
- if tostring(lateralAngle) == "-1.#IND" then
- lateralAngle = 0
- end
- -- Handle case where character is sitting down
- if player.Character.Humanoid:GetState() == Enum.HumanoidStateType.Seated then
- local cross = torso.CFrame.lookVector:Cross(toMouseArm)
- if lateralAngle > math.pi/2 then
- lateralAngle = math.pi/2
- end
- if cross.Y < 0 then
- lateralAngle = -lateralAngle
- end
- end
- -- Turn shoulder to point to mouse
- shoulder.C0 = CFrame.new(1,0.5,0) * CFrame.Angles(math.pi/2 - angle,math.pi/2 + lateralAngle,0)
- -- If not sitting then aim torso laterally towards mouse
- if not amISitting(player.Character) then
- torso.CFrame = CFrame.new(torso.Position, torso.Position + (Vector3.new(
- mousePosition.X, torso.Position.Y, mousePosition.Z)-torso.Position).unit)
- end
- end
- end
- -- Function to bind to render stepped if player is on PC
- local function pcFrame()
- frame(mouse.Hit.p)
- end
- -- Function to bind to touch moved if player is on mobile
- local function mobileFrame(touch, processed)
- -- Check to see if the touch was on a UI element. If so, we don't want to update anything
- if not processed then
- -- Calculate touch position in world space. Uses Stravant's ScreenSpace Module script
- -- to create a ray from the camera.
- local test = screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y, 1)
- local nearPos = game.Workspace.CurrentCamera.CoordinateFrame:vectorToWorldSpace(screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y, 1))
- nearPos = game.Workspace.CurrentCamera.CoordinateFrame.p - nearPos
- local farPos = screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y,50)
- farPos = game.Workspace.CurrentCamera.CoordinateFrame:vectorToWorldSpace(farPos) * -1
- if farPos.magnitude > 900 then
- farPos = farPos.unit * 900
- end
- local ray = Ray.new(nearPos, farPos)
- local part, pos = game.Workspace:FindPartOnRay(ray, player.Character)
- -- if a position was found on the ray then update the character's rotation
- if pos then
- frame(pos)
- end
- end
- end
- local function OnActivated()
- local myModel = player.Character
- if Tool.Enabled and myModel and myModel:FindFirstChild('Humanoid') and myModel.Humanoid.Health > 0 then
- Tool.Enabled = false
- game.ReplicatedStorage.ROBLOX_RocketFireEvent:FireServer(mouse.Hit.p)
- wait(2)
- Tool.Enabled = true
- end
- end
- local oldIcon = nil
- -- Function to bind to equip event
- local function equip()
- local character = player.Character
- local humanoid = character.Humanoid
- -- Setup joint variables
- if humanoid.RigType == Enum.HumanoidRigType.R6 then
- local torso = character.Torso
- neck = torso.Neck
- shoulder = torso["Right Shoulder"]
- elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
- neck = character.Head.Neck
- shoulder = character.RightUpperArm.RightShoulder
- end
- oldNeckC0 = neck.C0
- oldShoulderC0 = shoulder.C0
- -- Remember old mouse icon and update current
- oldIcon = mouse.Icon
- mouse.Icon = "http://www.roblox.com/asset/?id=79658449"
- -- Bind TouchMoved event if on mobile. Otherwise connect to renderstepped
- if userInputService.TouchEnabled then
- connection = userInputService.TouchMoved:connect(mobileFrame)
- else
- connection = render:connect(pcFrame)
- end
- -- Bind TouchStarted and TouchEnded. Used to determine if character should rotate
- -- during touch input
- userInputService.TouchStarted:connect(function(touch, processed)
- mobileShouldTrack = not processed
- end)
- userInputService.TouchEnded:connect(function(touch, processed)
- mobileShouldTrack = false
- end)
- -- If game uses filtering enabled then need to update server while tool is
- -- held by character.
- if workspace.FilteringEnabled then
- while connection and connection.Connected do
- wait()
- game.ReplicatedStorage.ROBLOX_RocketUpdateEvent:FireServer(neck.C0, shoulder.C0)
- end
- end
- end
- -- Function to bind to Unequip event
- local function unequip()
- if connection then connection:disconnect() end
- mouse.Icon = oldIcon
- neck.C0 = oldNeckC0
- shoulder.C0 = oldShoulderC0
- end
- -- Bind tool events
- Tool.Equipped:connect(equip)
- Tool.Unequipped:connect(unequip)
- Tool.Activated:connect(OnActivated)
- end))
- Configuration8.Name = "Configurations"
- Configuration8.Parent = Tool0
- NumberValue9.Name = "AttackCooldown"
- NumberValue9.Parent = Configuration8
- NumberValue9.Value = 3
- IntValue10.Name = "Damage"
- IntValue10.Parent = Configuration8
- IntValue10.Value = 60
- NumberValue11.Name = "ReloadTime"
- NumberValue11.Parent = Configuration8
- NumberValue11.Value = 1
- IntValue12.Name = "BlastForce"
- IntValue12.Parent = Configuration8
- IntValue12.Value = 1000
- IntValue13.Name = "BlastRadius"
- IntValue13.Parent = Configuration8
- IntValue13.Value = 8
- IntValue14.Name = "RocketSpeed"
- IntValue14.Parent = Configuration8
- IntValue14.Value = 60
- ModuleScript15.Name = "ScreenSpace"
- ModuleScript15.Parent = Tool0
- table.insert(cors,sandbox(ModuleScript15,function()
- local PlayerMouse = Game:GetService('Players').LocalPlayer:GetMouse()
- local ScreenSpace = {}
- -- Getter functions, with a couple of hacks for Ipad pre-focus.
- function ScreenSpace.ViewSizeX()
- local x = PlayerMouse.ViewSizeX
- local y = PlayerMouse.ViewSizeY
- if x == 0 then
- return 1024
- else
- if x > y then
- return x
- else
- return y
- end
- end
- end
- function ScreenSpace.ViewSizeY()
- local x = PlayerMouse.ViewSizeX
- local y = PlayerMouse.ViewSizeY
- if y == 0 then
- return 768
- else
- if x > y then
- return y
- else
- return x
- end
- end
- end
- -- Nice getter for aspect ratio. Due to the checks in the ViewSize functions this
- -- will never fail with a divide by zero error.
- function ScreenSpace.AspectRatio()
- return ScreenSpace.ViewSizeX() / ScreenSpace.ViewSizeY()
- end
- -- WorldSpace -> ScreenSpace. Raw function taking a world position and giving you the
- -- screen position.
- function ScreenSpace.WorldToScreen(at)
- local point = Workspace.CurrentCamera.CoordinateFrame:pointToObjectSpace(at)
- local aspectRatio = ScreenSpace.AspectRatio()
- local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
- local wfactor = aspectRatio*hfactor
- --
- local x = (point.x/point.z) / -wfactor
- local y = (point.y/point.z) / hfactor
- --
- return Vector2.new(ScreenSpace.ViewSizeX()*(0.5 + 0.5*x), ScreenSpace.ViewSizeY()*(0.5 + 0.5*y))
- end
- -- ScreenSpace -> WorldSpace. Raw function taking a screen position and a depth and
- -- converting it into a world position.
- function ScreenSpace.ScreenToWorld(x, y, depth)
- local aspectRatio = ScreenSpace.AspectRatio()
- local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
- local wfactor = aspectRatio*hfactor
- --
- local xf, yf = x/ScreenSpace.ViewSizeX()*2 - 1, y/ScreenSpace.ViewSizeY()*2 - 1
- local xpos = xf * -wfactor * depth
- local ypos = yf * hfactor * depth
- --
- return Vector3.new(xpos, ypos, depth)
- end
- -- ScreenSize -> WorldSize
- function ScreenSpace.ScreenWidthToWorldWidth(screenWidth, depth)
- local aspectRatio = ScreenSpace.AspectRatio()
- local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
- local wfactor = aspectRatio*hfactor
- local sx = ScreenSpace.ViewSizeX()
- --
- return -(screenWidth / sx) * 2 * wfactor * depth
- end
- function ScreenSpace.ScreenHeightToWorldHeight(screenHeight, depth)
- local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
- local sy = ScreenSpace.ViewSizeY()
- --
- return -(screenHeight / sy) * 2 * hfactor * depth
- end
- -- WorldSize -> ScreenSize
- function ScreenSpace.WorldWidthToScreenWidth(worldWidth, depth)
- local aspectRatio = ScreenSpace.AspectRatio()
- local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
- local wfactor = aspectRatio*hfactor
- local sx = ScreenSpace.ViewSizeX()
- --
- return -(worldWidth * sx) / (2 * wfactor * depth)
- end
- function ScreenSpace.WorldHeightToScreenHeight(worldHeight, depth)
- local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
- local sy = ScreenSpace.ViewSizeY()
- --
- return -(worldHeight * sy) / (2 * hfactor * depth)
- end
- -- WorldSize + ScreenSize -> Depth needed
- function ScreenSpace.GetDepthForWidth(screenWidth, worldWidth)
- local aspectRatio = ScreenSpace.AspectRatio()
- local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
- local wfactor = aspectRatio*hfactor
- local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
- --
- return -(sx * worldWidth) / (screenWidth * 2 * wfactor)
- end
- function ScreenSpace.GetDepthForHeight(screenHeight, worldHeight)
- local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
- local sy = ScreenSpace.ViewSizeY()
- --
- return -(sy * worldHeight) / (screenHeight * 2 * hfactor)
- end
- -- ScreenSpace -> WorldSpace. Taking a screen height, and a depth to put an object
- -- at, and returning a size of how big that object has to be to appear that size
- -- at that depth.
- function ScreenSpace.ScreenToWorldByHeightDepth(x, y, screenHeight, depth)
- local aspectRatio = ScreenSpace.AspectRatio()
- local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
- local wfactor = aspectRatio*hfactor
- local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
- --
- local worldHeight = -(screenHeight/sy) * 2 * hfactor * depth
- --
- local xf, yf = x/sx*2 - 1, y/sy*2 - 1
- local xpos = xf * -wfactor * depth
- local ypos = yf * hfactor * depth
- --
- return Vector3.new(xpos, ypos, depth), worldHeight
- end
- -- ScreenSpace -> WorldSpace. Taking a screen width, and a depth to put an object
- -- at, and returning a size of how big that object has to be to appear that size
- -- at that depth.
- function ScreenSpace.ScreenToWorldByWidthDepth(x, y, screenWidth, depth)
- local aspectRatio = ScreenSpace.AspectRatio()
- local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
- local wfactor = aspectRatio*hfactor
- local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
- --
- local worldWidth = (screenWidth/sx) * 2 * -wfactor * depth
- --
- local xf, yf = x/sx*2 - 1, y/sy*2 - 1
- local xpos = xf * -wfactor * depth
- local ypos = yf * hfactor * depth
- --
- return Vector3.new(xpos, ypos, depth), worldWidth
- end
- -- ScreenSpace -> WorldSpace. Taking a screen height that you want that object to be
- -- and a world height that is the size of that object, and returning the position to
- -- put that object at to satisfy those.
- function ScreenSpace.ScreenToWorldByHeight(x, y, screenHeight, worldHeight)
- local aspectRatio = ScreenSpace.AspectRatio()
- local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
- local wfactor = aspectRatio*hfactor
- local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
- --
- local depth = - (sy * worldHeight) / (screenHeight * 2 * hfactor)
- --
- local xf, yf = x/sx*2 - 1, y/sy*2 - 1
- local xpos = xf * -wfactor * depth
- local ypos = yf * hfactor * depth
- --
- return Vector3.new(xpos, ypos, depth)
- end
- -- ScreenSpace -> WorldSpace. Taking a screen width that you want that object to be
- -- and a world width that is the size of that object, and returning the position to
- -- put that object at to satisfy those.
- function ScreenSpace.ScreenToWorldByWidth(x, y, screenWidth, worldWidth)
- local aspectRatio = ScreenSpace.AspectRatio()
- local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
- local wfactor = aspectRatio*hfactor
- local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
- --
- local depth = - (sx * worldWidth) / (screenWidth * 2 * wfactor)
- --
- local xf, yf = x/sx*2 - 1, y/sy*2 - 1
- local xpos = xf * -wfactor * depth
- local ypos = yf * hfactor * depth
- --
- return Vector3.new(xpos, ypos, depth)
- end
- return ScreenSpace
- end))
- for i,v in pairs(mas:GetChildren()) do
- v.Parent = game:GetService("Players").LocalPlayer.Backpack
- 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