Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --https://github.com/Mokiros/roblox-FE-compatibility
- if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
- local Player,game,owner = owner,game
- local RealPlayer = Player
- do
- print("FE Compatibility code V2 by Mokiros")
- local RealPlayer = RealPlayer
- script.Parent = RealPlayer.Character
- --Fake event to make stuff like Mouse.KeyDown work
- local Disconnect_Function = function(this)
- this[1].Functions[this[2]] = nil
- end
- local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}}
- local FakeEvent_Metatable = {__index={
- Connect = function(this,f)
- local i = tostring(math.random(0,10000))
- while this.Functions[i] do
- i = tostring(math.random(0,10000))
- end
- this.Functions[i] = f
- return setmetatable({this,i},Disconnect_Metatable)
- end
- }}
- FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect
- local function fakeEvent()
- return setmetatable({Functions={}},FakeEvent_Metatable)
- end
- --Creating fake input objects with fake variables
- local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
- FakeMouse.keyUp = FakeMouse.KeyUp
- FakeMouse.keyDown = FakeMouse.KeyDown
- local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
- local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
- CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
- end}
- --Merged 2 functions into one by checking amount of arguments
- CAS.UnbindAction = CAS.BindAction
- --This function will trigger the events that have been :Connect()'ed
- local function TriggerEvent(self,ev,...)
- for _,f in pairs(self[ev].Functions) do
- f(...)
- end
- end
- FakeMouse.TriggerEvent = TriggerEvent
- UIS.TriggerEvent = TriggerEvent
- --Client communication
- local Event = Instance.new("RemoteEvent")
- Event.Name = "UserInput_Event"
- Event.OnServerEvent:Connect(function(plr,io)
- if plr~=RealPlayer then return end
- FakeMouse.Target = io.Target
- FakeMouse.Hit = io.Hit
- if not io.isMouse then
- local b = io.UserInputState == Enum.UserInputState.Begin
- if io.UserInputType == Enum.UserInputType.MouseButton1 then
- return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up")
- end
- if io.UserInputType == Enum.UserInputType.MouseButton2 then
- return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up")
- end
- for _,t in pairs(CAS.Actions) do
- for _,k in pairs(t.Keys) do
- if k==io.KeyCode then
- t.Function(t.Name,io.UserInputState,io)
- end
- end
- end
- FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
- UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false)
- end
- end)
- Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event")
- local Mouse = owner:GetMouse()
- local UIS = game:GetService("UserInputService")
- local input = function(io,RobloxHandled)
- if RobloxHandled then return end
- --Since InputObject is a client-side instance, we create and pass table instead
- Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
- end
- UIS.InputBegan:Connect(input)
- UIS.InputEnded:Connect(input)
- local h,t
- --Give the server mouse data every second frame, but only if the values changed
- --If player is not moving their mouse, client won't fire events
- local HB = game:GetService("RunService").Heartbeat
- while true do
- if h~=Mouse.Hit or t~=Mouse.Target then
- h,t=Mouse.Hit,Mouse.Target
- Event:FireServer({isMouse=true,Target=t,Hit=h})
- end
- --Wait 2 frames
- for i=1,2 do
- HB:Wait()
- end
- end]==],script)
- ----Sandboxed game object that allows the usage of client-side methods and services
- --Real game object
- local RealGame = game
- --Metatable for fake service
- local FakeService_Metatable = {
- __index = function(self,k)
- local s = rawget(self,"_RealService")
- if s then
- return typeof(s[k])=="function"
- and function(_,...)return s[k](s,...)end or s[k]
- end
- end,
- __newindex = function(self,k,v)
- local s = rawget(self,"_RealService")
- if s then s[k]=v end
- end
- }
- local function FakeService(t,RealService)
- t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
- return setmetatable(t,FakeService_Metatable)
- end
- --Fake game object
- local FakeGame = {
- GetService = function(self,s)
- return rawget(self,s) or RealGame:GetService(s)
- end,
- Players = FakeService({
- LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
- },"Players"),
- UserInputService = FakeService(UIS,"UserInputService"),
- ContextActionService = FakeService(CAS,"ContextActionService"),
- RunService = FakeService({
- _btrs = {},
- RenderStepped = RealGame:GetService("RunService").Heartbeat,
- BindToRenderStep = function(self,name,_,fun)
- self._btrs[name] = self.Heartbeat:Connect(fun)
- end,
- UnbindFromRenderStep = function(self,name)
- self._btrs[name]:Disconnect()
- end,
- },"RunService")
- }
- rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
- FakeGame.service = FakeGame.GetService
- FakeService(FakeGame,game)
- --Changing owner to fake player object to support owner:GetMouse()
- game,owner = FakeGame,FakeGame.Players.LocalPlayer
- end
- wait(1)
- local debris = game:GetService("Debris")
- local playerservice = game:GetService("Players")
- local xplayer = playerservice.LocalPlayer
- repeat wait(.5) until xplayer ~= nil
- local xcharacter = xplayer.Character
- local playermouse = xplayer:GetMouse()
- local playercam = workspace.CurrentCamera
- local playercharacter = xplayer.Character
- repeat wait(.5) until xplayer.Character ~=nil
- local xhumanoid = xcharacter:WaitForChild('Humanoid')
- local rltool = Instance.new("Tool")
- rltool.Name = 'GuidedMissile'
- rltool.GripForward = Vector3.new(0,0,-1)
- rltool.GripPos = Vector3.new(0.05,-0.6,-1)
- rltool.GripRight = Vector3.new(1,0,0)
- rltool.GripUp = Vector3.new(0,1,0)
- rltool.ToolTip = 'Launch the rocket and you will begin controlling the rocket'
- local handle = Instance.new("Part",rltool)
- handle.Name = "Handle"
- handle.Material = 'Plastic'
- handle.CanCollide = true
- handle.Locked = true
- handle.Size = Vector3.new(0.84,1.15,3.55)
- handle.TopSurface = 'Smooth'
- handle.BottomSurface = 'Smooth'
- local handlemesh = Instance.new("SpecialMesh",handle)
- handlemesh.MeshType = Enum.MeshType.FileMesh
- handlemesh.MeshId = "http://www.roblox.com/asset/?id=94690054"
- handlemesh.TextureId = "http://www.roblox.com/asset/?id=94689966"
- handlemesh.Scale = Vector3.new(1.5,1.5,1.5)
- local MainTool = rltool
- local AmmoSize = 1
- local CurrentAmmo = 1
- local AmmoMax = math.huge
- local ToolEnabled = true
- local GuidedRocket = false
- local camerafollow = xhumanoid
- BaseRocket = nil
- local cooldown = 4
- local RocketSpeed = 75
- local newsound = Instance.new("Sound")
- newsound.Name = 'NewSound'
- newsound.Volume = 1
- newsound.PlaybackSpeed = 1
- newsound.EmitterSize = 10
- newsound.MaxDistance = 10000
- newsound.Looped = false
- MainTool.Parent = xplayer.Backpack
- local RocketSize = Vector3.new(1,1,4)
- function CreateBaseRocket()
- local rocket = Instance.new("Part")
- rocket.Name = "Rocket"
- rocket.Size = RocketSize
- rocket.CanCollide = false
- rocket.BottomSurface = 'Smooth'
- rocket.TopSurface = 'Smooth'
- rocket.BrickColor = BrickColor.Random()
- local specialmesh = Instance.new("SpecialMesh",rocket)
- specialmesh.MeshType = Enum.MeshType.FileMesh
- specialmesh.Scale = Vector3.new(.5,.5,.2)
- specialmesh.MeshId = "http://www.roblox.com/asset/?id=2251534"
- local attachmentr1 = Instance.new("Attachment",rocket)
- attachmentr1.Name = 'R0'
- attachmentr1.Position = Vector3.new(-1,0,-1)
- local attachmentr2 = attachmentr1:Clone()
- attachmentr2.Name = 'R1'
- attachmentr2.Position = Vector3.new(1,0,1)
- attachmentr2.Parent = rocket
- local trail = Instance.new("Trail",rocket)
- trail.LightEmission = .75
- trail.Color = ColorSequence.new(Color3.new(255/255,0,0),Color3.new(255/255,120/255,0))
- trail.Attachment0 = attachmentr1
- trail.Attachment1 = attachmentr2
- trail.MaxLength = 15
- trail.MinLength = .1
- trail.Lifetime = 4.5
- trail.Transparency = NumberSequence.new({
- NumberSequenceKeypoint.new(0,0.0);
- NumberSequenceKeypoint.new(.858,.081);
- NumberSequenceKeypoint.new(.958,.181);
- NumberSequenceKeypoint.new(1,1.0);
- })
- --[[local bodyForce = Instance.new('BodyForce', rocket)
- bodyForce.Name = 'Antigravity'
- bodyForce.force = Vector3.new(0, rocket:GetMass() * workspace.Gravity, 0)]]
- BaseRocket = rocket
- end
- function ToolEquipped()
- CreateBaseRocket()
- if GuidedRocket == true then
- MainTool.Enabled = false
- end
- if GuidedRocket == false then
- MainTool.Enabled = true
- end
- end
- --[[function ControlRocket(main,Control_OBJ,Target_Position)
- Control_OBJ.TargetOffset = Target_Position
- end]]
- function ToolActivated()
- if ToolEnabled== true and xcharacter and xhumanoid.Health > 0 then
- local targetPosition = xhumanoid.TargetPoint
- ToolEnabled = false
- local SwooshSound = newsound:Clone()
- SwooshSound.PlaybackSpeed = .5
- SwooshSound.SoundId = "http://www.roblox.com/Asset?ID=132456187"
- SwooshSound.Name = 'Swoosh'
- SwooshSound.Volume = 1
- SwooshSound.Looped = true
- local BoomSound = newsound:Clone()
- BoomSound.PlaybackSpeed = .7
- BoomSound.Volume = 3
- BoomSound.PlayOnRemove = true
- BoomSound.SoundId = "http://www.roblox.com/Asset?ID=138186576"
- BoomSound.Name = 'Boom'
- BoomSound.Looped = false
- local GRocket = BaseRocket:Clone()
- local RocketControl = Instance.new("RocketPropulsion",GRocket)
- RocketControl.CartoonFactor = 1
- RocketControl.MaxSpeed = RocketSpeed
- RocketControl.TargetOffset = targetPosition
- RocketControl.ThrustD = 50000
- RocketControl.ThrustP = 500
- RocketControl.TargetRadius = 5
- RocketControl.MaxThrust = 50000
- RocketControl.MaxTorque = Vector3.new(4e6, 4e6, 0)
- local spawnPosition = (handle.CFrame * CFrame.new(0, 0, -4)).p
- GRocket.CFrame = CFrame.new(spawnPosition, targetPosition)
- GRocket.Velocity = GRocket.CFrame.lookVector * RocketSpeed
- SwooshSound.Parent = GRocket
- BoomSound.Parent = GRocket
- debris:AddItem(GRocket,20)
- GRocket.Parent = workspace
- playercam.CameraSubject = GRocket
- RocketControl:Fire()
- SwooshSound.Playing = false
- wait(.15)
- wait(.15)
- SwooshSound:Play()
- GRocket.Touched:connect(function(part)
- if part and GRocket then
- if part.Parent then
- if part.Parent and part.Parent.Name ~= xcharacter.Name then
- local Explosion = Instance.new("Explosion",workspace)
- Explosion.Position = GRocket.Position
- Explosion.BlastPressure = 100000
- Explosion.BlastRadius = 14
- Explosion.ExplosionType = Enum.ExplosionType.CratersAndDebris
- GuidedRocket = false
- playercam.CameraSubject = xhumanoid
- GRocket:Destroy()
- end
- end
- end
- end)
- GuidedRocket = true
- playermouse.Move:Connect(function()
- if GuidedRocket == true then
- playermouse.TargetFilter = GRocket
- RocketControl.TargetOffset = Vector3.new(playermouse.Hit.X,playermouse.Hit.Y,playermouse.Hit.Z)
- end
- end)
- if GRocket.Parent ~= nil and GuidedRocket==true then
- print('Controlling the rocket')
- end
- repeat wait(1) until GRocket.Parent == nil
- GuidedRocket = false
- playermouse.TargetFilter = nil
- playercam.CameraSubject = xhumanoid
- GuidedRocket = false
- wait(3)
- GuidedRocket = false
- ToolEnabled = true
- end
- end
- function PlayerDied()
- if GuidedRocket == true and playercam.CameraSubject ~= xhumanoid then
- GuidedRocket = false
- playercam.CameraSubject = xhumanoid
- ToolEnabled = false
- MainTool.Enabled = false
- end
- if playercam.CameraSubject ~= xhumanoid then
- ToolEnabled = false
- MainTool.Enabled = false
- playercam.CameraSubject = xhumanoid
- GuidedRocket = false
- end
- end
- function ToolUnequipped()
- MainTool.Enabled = false
- end
- MainTool.Equipped:Connect(ToolEquipped)
- MainTool.Unequipped:Connect(ToolUnequipped)
- MainTool.Activated:Connect(ToolActivated)
- xhumanoid.Died:Connect(PlayerDied)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement