Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 by Mokiros")
- local rp = RealPlayer
- script.Parent = rp.Character
- --RemoteEvent for communicating
- local Event = Instance.new("RemoteEvent")
- Event.Name = "UserInput_Event"
- --Fake event to make stuff like Mouse.KeyDown work
- local function fakeEvent()
- local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
- t.connect = t.Connect
- return t
- end
- --Creating fake input objects with fake variables
- local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
- 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 te(self,ev,...)
- local t = m[ev]
- if t and t._fakeEvent then
- for _,f in pairs(t.Functions) do
- f(...)
- end
- end
- end
- m.TrigEvent = te
- UIS.TrigEvent = te
- Event.OnServerEvent:Connect(function(plr,io)
- if plr~=rp then return end
- m.Target = io.Target
- m.Hit = io.Hit
- if not io.isMouse then
- local b = io.UserInputState == Enum.UserInputState.Begin
- if io.UserInputType == Enum.UserInputType.MouseButton1 then
- return m:TrigEvent(b and "Button1Down" or "Button1Up")
- end
- if io.UserInputType == Enum.UserInputType.MouseButton2 then
- return m:TrigEvent(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
- m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
- UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
- end
- end)
- Event.Parent = NLS([==[
- local Player = game:GetService("Players").LocalPlayer
- local Event = script:WaitForChild("UserInput_Event")
- local Mouse = Player:GetMouse()
- local UIS = game:GetService("UserInputService")
- local input = function(io,a)
- if a 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 30 times every second, but only if the values changed
- --If player is not moving their mouse, client won't fire events
- while wait(1/30) 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
- end]==],Player.Character)
- ----Sandboxed game object that allows the usage of client-side methods and services
- --Real game object
- local _rg = game
- --Metatable for fake service
- local fsmt = {
- __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 _rg:GetService(RealService) or RealService
- return setmetatable(t,fsmt)
- end
- --Fake game object
- local g = {
- GetService = function(self,s)
- return rawget(self,s) or _rg:GetService(s)
- end,
- Players = FakeService({
- LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
- },"Players"),
- UserInputService = FakeService(UIS,"UserInputService"),
- ContextActionService = FakeService(CAS,"ContextActionService"),
- RunService = FakeService({
- _btrs = {},
- RenderStepped = _rg: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(g.Players,"localPlayer",g.Players.LocalPlayer)
- g.service = g.GetService
- FakeService(g,game)
- --Changing owner to fake player object to support owner:GetMouse()
- game,owner = g,g.Players.LocalPlayer
- end
- char = game.Players.LocalPlayer.Character
- player = game.Players.LocalPlayer
- mouse = player:GetMouse()
- mas = char
- shooting = false
- Part0 = Instance.new("Part")
- SpecialMesh1 = Instance.new("SpecialMesh")
- Part0.Name = "Assault Rifle"
- Part0.Parent = mas
- function shootsound()
- coroutine.resume(coroutine.create(function()
- shoot = Instance.new("Sound",Part0)
- shoot.Volume = 10
- shoot.PlaybackSpeed = 1
- shoot.SoundId = "rbxassetid://3289652262"
- shoot:Play()
- wait(2)
- shoot:Destroy()
- end))
- end
- Part0.CFrame = CFrame.new(-7.32639599, 14.2976122, 14.3406916, -0.106925137, 0.994266748, 0.000791709346, 1.85333519e-12, -0.000796274282, 0.999999642, 0.994266987, 0.106925115, 8.51417499e-05)
- Part0.Orientation = Vector3.new(-89.9499969, 83.8600006, 180)
- Part0.Position = Vector3.new(-7.32639599, 14.2976122, 14.3406916)
- Part0.Rotation = Vector3.new(-90, 0.0500000007, -96.1399994)
- Part0.Color = Color3.new(0.105882, 0.164706, 0.207843)
- Part0.Size = Vector3.new(0.400000006, 3.4000001, 0.800000012)
- Part0.BrickColor = BrickColor.new("Black")
- Part0.brickColor = BrickColor.new("Black")
- Part0.FormFactor = Enum.FormFactor.Custom
- Part0.CanCollide = false
- Part0.formFactor = Enum.FormFactor.Custom
- SpecialMesh1.Parent = Part0
- SpecialMesh1.MeshId = "http://www.roblox.com/asset/?id=72012671"
- SpecialMesh1.VertexColor = Vector3.new(2, 2, 2)
- SpecialMesh1.TextureId = "http://www.roblox.com/asset/?id=72012605"
- SpecialMesh1.MeshType = Enum.MeshType.FileMesh
- weld = Instance.new("Weld",Part0)
- weld.Part0 = char["Right Arm"]
- weld.Part1 = Part0
- weld.C0 = CFrame.new(0,-1.5,-0.5) * CFrame.Angles(math.rad(180),math.rad(0),math.rad(-30))
- rs = Instance.new("Weld",char.Torso)
- rs.Part0 = char.Torso["Right Shoulder"].Part0
- rs.Part1 = char.Torso["Right Shoulder"].Part1
- rs.C0 = CFrame.new(0.5,0.5,-0.5) * CFrame.Angles(math.rad(0),math.rad(120),math.rad(90))
- rs.C1 = char.Torso["Right Shoulder"].C1
- ls = Instance.new("Weld",char.Torso)
- ls.Part0 = char.Torso["Left Shoulder"].Part0
- ls.Part1 = char.Torso["Left Shoulder"].Part1
- ls.C0 = CFrame.new(-0.6,0.5,-1) * CFrame.Angles(math.rad(180),math.rad(-57),math.rad(90))
- ls.C1 = char.Torso["Left Shoulder"].C1
- Weld1 = Instance.new("Weld")
- BillboardGui2 = Instance.new("BillboardGui")
- ImageLabel3 = Instance.new("ImageLabel")
- Part02 = Instance.new("Part")
- Part02.Parent = Part0
- Part02.CFrame = CFrame.new(-7.52682972, 18.6985626, 9.31794739, 1, -5.96046448e-08, 6.5567086e-08, -6.55670789e-08, 1.1356552e-07, 1, -5.96046448e-08, -1, 1.1356552e-07)
- Part02.Orientation = Vector3.new(-90, 0, 0)
- Part02.Position = Vector3.new(-7.52682972, 18.6985626, 9.31794739)
- Part02.Rotation = Vector3.new(-90, 0, 0)
- Part02.Transparency = 1
- Part02.Size = Vector3.new(1, 1, 1)
- Part02.BottomSurface = Enum.SurfaceType.Smooth
- Part02.TopSurface = Enum.SurfaceType.Smooth
- Weld1.Parent = Part02
- Weld1.C0 = CFrame.new(0, 2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
- Weld1.Part0 = Part0
- Weld1.Part1 = Part02
- Weld1.part1 = Part02
- BillboardGui2.Parent = Part02
- BillboardGui2.LightInfluence = 1
- BillboardGui2.Size = UDim2.new(2, 0, 2, 0)
- BillboardGui2.Active = true
- BillboardGui2.ClipsDescendants = true
- BillboardGui2.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
- ImageLabel3.Parent = BillboardGui2
- ImageLabel3.Size = UDim2.new(1, 0, 1, 0)
- ImageLabel3.BackgroundColor = BrickColor.new("Institutional white")
- ImageLabel3.BackgroundColor3 = Color3.new(1, 1, 1)
- ImageLabel3.BackgroundTransparency = 1
- ImageLabel3.ImageTransparency = 1
- ImageLabel3.Image = "http://www.roblox.com/asset/?id=156580315"
- head = char.Head
- game:GetService("RunService").RenderStepped:Connect(function()
- if shooting == true then
- shootsound()
- ImageLabel3.ImageTransparency = 0
- ImageLabel3.Rotation = ImageLabel3.Rotation + 90
- if mouse.Target.Anchored == false then
- p = mouse.Target
- p.Velocity = Vector3.new(p.Velocity.X + (head.CFrame.lookVector.X * 18), p.Velocity.Y + (head.CFrame.lookVector.Y * 18) + 8, p.Velocity.Z + (head.CFrame.lookVector.Z * 18))
- end
- if mouse.Target.Parent:FindFirstChildOfClass("Humanoid") then
- mouse.Target.Parent:FindFirstChildOfClass("Humanoid").Health = mouse.Target.Parent:FindFirstChildOfClass("Humanoid").Health - 43.5
- end
- wait(0.6)
- else
- ImageLabel3.ImageTransparency = 1
- end
- end)
- mouse.Button1Down:Connect(function()
- shooting = true
- end)
- mouse.Button1Up:Connect(function()
- shooting = false
- end)
Add Comment
Please, Sign In to add comment