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
- --Past this line is the main code, above this line would be Voidacity Compatibility thing
- local t = Instance.new("Tool",owner.Backpack)
- t.Name = "Whitworth Rifle"
- t.GripForward = Vector3.new(1, -0, 0)
- t.GripRight = Vector3.new(0, 0, 1)
- t.GripUp = Vector3.new(0, 1, -0)
- t.GripPos = Vector3.new(-1, -0.1, -0.1)
- local h = Instance.new("Part",t)
- h.Name = "Handle"
- h.BrickColor = BrickColor.Black()
- local m = Instance.new("FileMesh",h)
- m.MeshId = "rbxassetid://583551291"
- m.TextureId = "rbxassetid://583551296"
- m.Scale = Vector3.new(0.01,0.01,0.01)
- local fire = Instance.new("PointLight",h)
- fire.Color = Color3.fromRGB(255, 255, 0)
- fire.Enabled = false
- h.CFrame = CFrame.new(219.5, 1.77000618, 75, 1, 1.13660383e-13, 0, 1.13660383e-13, 1, 0, 0, 0, 1)
- h.Position = Vector3.new(219.5, 1.77000618, 75)
- local cam = workspace.CurrentCamera
- local cooldown = 60/60 --Property 1
- local rate = 60/900 --Property 2
- local bursts = 5 --Property 3
- local damage = (29/7.62)*(9/1) --Property 4
- print(damage)
- local penetration = 9*2 --Property 5
- local range = 300*2.4 --Property 6
- local recoil = 45 --Propety 7, this is toolgrip recoil
- local suppressed = false --Property 8
- local fired = false
- fire.Brightness = recoil/10
- local s
- --ARMS
- --Sound variable
- local fs = Instance.new("Sound",h)
- fs.SoundId = "rbxassetid://2739880827"
- fs.Volume = 10
- fs.MaxDistance = math.huge
- local firepitch = 1
- if suppressed == true then
- firepitch = firepitch*2
- fs.Volume = 1.25
- range = range*0.8
- end
- local mouse2 = owner:GetMouse()
- local aiming = false
- t.Activated:connect(function()
- if fired == false then
- fired = true
- for i = 1,bursts do
- fs.PlaybackSpeed = fs.PlaybackSpeed + (math.random(-6,6)/10)
- NLS([==[
- recoil = 45
- recoil = recoil/5
- workspace.CurrentCamera.CFrame=workspace.CurrentCamera.CFrame*CFrame.Angles(math.random(recoil*1,recoil*1.25)/360,math.random(recoil/1.5,recoil/1.5)/360,math.random(recoil*-1/1.5,recoil/1.5)/360)]==],script)
- local m = owner:GetMouse()
- fs:Play()
- local impact = Instance.new("Part")
- impact.Size = Vector3.new(0.5,0.5,0.5)
- impact.Shape = 0
- impact.Transparency = 0.5
- impact.Anchored = true
- impact.Position = m.Hit.p
- impact.CanCollide = false
- if m.Target ~= nil then --search workspace for le target
- local Dis = h.Position.Magnitude - m.Target.Position.Magnitude
- local Distance = Dis
- if Distance <= 0 then
- Distance = Distance*(-1)
- end
- print(Distance)
- if Distance <= range then
- --m.Target:BreakJoints()
- impact.Position = m.Target.Position
- impact.Parent = workspace
- if m.Target.Locked ~= true then
- m.Target.Transparency = m.Target.Transparency + (penetration-((penetration/2)/Distance))/750
- end
- if m.Target.parent ~= nil and m.Target.Parent:IsA("Accessory") then
- m.Target:BreakJoints()
- m.Target.CanCollide = true
- m.Target.Velocity = m.Target.CFrame.LookVector*(range*-0.1)
- end
- if m.Target.parent ~= nil and m.Target.Parent:IsA("Tool") then
- m.Target:BreakJoints()
- m.Target.Velocity = m.Target.CFrame.LookVector*(range*-0.1)
- m.Target.CanCollide = true
- m.Target.Parent.Parent = workspace
- end
- if m.Target.Transparency >= 1 then
- m.Target:Destroy()
- end
- local t2
- if m.Target.Parent ~= nil then
- t2 = m.Target.Parent:FindFirstChild("Humanoid")
- end
- if t2~=nil then
- -- is1 = Instance.new("Sound",m.Target)
- -- is1.SoundId = "rbxassetid://255661850"
- -- is1.Volume = 1
- -- is1.PlayOnRemove = true
- -- is1:Destroy()
- local distancedamage = damage-((damage/2)/Distance)
- if m.Target.Name == "Head" then
- distancedamage = distancedamage*5.6
- m.Target.Velocity = m.Target.CFrame.LookVector*(range*-0.01)
- end
- if m.Target.Name == "Torso" or m.Target.Name == "UpperTorso" then
- distancedamage = distancedamage*1.2
- end
- t2.Health = t2.Health - distancedamage
- t2.BreakJointsOnDeath = false
- m.Target.Transparency = m.Target.Transparency + distancedamage/3000
- local R = m.Target.BrickColor.Color.R+(distancedamage/(765/1))
- local G = m.Target.BrickColor.Color.G-(distancedamage/(255/2))
- local B = m.Target.BrickColor.Color.B-(distancedamage/(255/2))
- m.Target.BrickColor = BrickColor.new(R,G,B)
- t2.Sit = true
- if t2.Health <= t2.MaxHealth/4 then
- t2.Sit = false
- t2.PlatformStand = true
- end
- end
- end
- end
- t.GripPos = Vector3.new(t.GripPos.X + recoil/300,t.GripPos.Y,t.GripPos.Z )
- fire.Enabled = true
- wait(rate/2)
- t.GripPos = Vector3.new(t.GripPos.X - recoil/300,t.GripPos.Y,t.GripPos.Z)
- fire.Enabled = false
- impact:Destroy()
- wait(rate/2)
- end
- fs.PlaybackSpeed = firepitch
- wait(cooldown)
- fired = false
- end
- end)
- mouse2.KeyUp:connect(function(k)
- local key = k:lower()
- if key == "q" then
- if aiming == false then
- aiming = true
- NLS([==[workspace.CurrentCamera.FieldOfView = 70/3]==],script)
- for i = 1,10 do
- wait()
- t.GripPos = Vector3.new((-1/10)*i, (-0.38/10)*i, (1.37/10)*i) --0, -0.4, 1.3
- end
- mouse2.Icon = 'http://www.roblox.com/asset/?id=5225039196'
- t.GripPos = Vector3.new(-1, -0.38, 1.37)
- else
- aiming = false
- NLS([==[workspace.CurrentCamera.FieldOfView = 70]==],script)
- for i = 1,10 do
- wait()
- t.GripPos = Vector3.new((-1/i), (-0.38/i), (-1.37/i))
- end
- t.GripPos = Vector3.new(-1, -0.1, -0.1)
- mouse2.Icon = 'http://www.roblox.com/asset/?id=120149138'
- end
- end
- end)
- --http://www.roblox.com/asset/?id=5225039196
- t.Equipped:connect(function()
- mouse2.Icon = 'http://www.roblox.com/asset/?id=120149138'
- game.Players.LocalPlayer.CameraMode = "LockFirstPerson"
- end)
- t.Unequipped:connect(function()
- mouse2.Icon = ''
- game.Players.LocalPlayer.CameraMode = "Classic"
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement