View difference between Paste ID: EuKuHZBb and ntE08QwZ
SHOW: | | - or go back to the newest paste.
1
if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
2
local Player,player,plr,game,owner = owner,game
3
local RealPlayer = Player
4
do
5
    local rp = RealPlayer
6
    script.Parent = rp.Character
7
   
8
    --RemoteEvent for communicating
9
    local Event = Instance.new("RemoteEvent")
10
    Event.Name = "UserInput_Event"
11
 
12
    --Fake event to make stuff like Mouse.KeyDown work
13
    local function fakeEvent()
14
        local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
15-
plr = game.Players.LocalPlayer
15+
        t.connect = t.Connect
16
        return t
17
    end
18
 
19
    --Creating fake input objects with fake variables
20
    local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
21
    local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
22
    local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
23
        CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
24
    end}
25
    --Merged 2 functions into one by checking amount of arguments
26
    CAS.UnbindAction = CAS.BindAction
27
 
28
    --This function will trigger the events that have been :Connect()'ed
29
    local function te(self,ev,...)
30
        local t = m[ev]
31
        if t and t._fakeEvent then
32
            for _,f in pairs(t.Functions) do
33
                f(...)
34
            end
35
        end
36
    end
37
    m.TrigEvent = te
38
    UIS.TrigEvent = te
39
 
40
    Event.OnServerEvent:Connect(function(plr,io)
41
        if plr~=rp then return end
42
        m.Target = io.Target
43
        m.Hit = io.Hit
44
        if not io.isMouse then
45
            local b = io.UserInputState == Enum.UserInputState.Begin
46
            if io.UserInputType == Enum.UserInputType.MouseButton1 then
47
                return m:TrigEvent(b and "Button1Down" or "Button1Up")
48
            end
49
            for _,t in pairs(CAS.Actions) do
50
                for _,k in pairs(t.Keys) do
51
                    if k==io.KeyCode then
52
                        t.Function(t.Name,io.UserInputState,io)
53
                    end
54
                end
55
            end
56
            m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
57
            UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
58
        end
59
    end)
60
    Event.Parent = NLS([==[
61
    local Player = game:GetService("Players").LocalPlayer
62
    local Event = script:WaitForChild("UserInput_Event")
63
 
64
    local Mouse = Player:GetMouse()
65
    local UIS = game:GetService("UserInputService")
66
    local input = function(io,a)
67
        if a then return end
68
        --Since InputObject is a client-side instance, we create and pass table instead
69
        Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
70
    end
71
    UIS.InputBegan:Connect(input)
72
    UIS.InputEnded:Connect(input)
73
 
74
    local h,t
75
    --Give the server mouse data 30 times every second, but only if the values changed
76
    --If player is not moving their mouse, client won't fire events
77
    while wait(1/30) do
78
        if h~=Mouse.Hit or t~=Mouse.Target then
79
            h,t=Mouse.Hit,Mouse.Target
80
            Event:FireServer({isMouse=true,Target=t,Hit=h})
81
        end
82
    end]==],Player.Character)
83
 
84
    ----Sandboxed game object that allows the usage of client-side methods and services
85
    --Real game object
86
    local _rg = game
87
 
88
    --Metatable for fake service
89
    local fsmt = {
90
        __index = function(self,k)
91
            local s = rawget(self,"_RealService")
92
            if s then return s[k] end
93
        end,
94
        __newindex = function(self,k,v)
95
            local s = rawget(self,"_RealService")
96
            if s then s[k]=v end
97
        end,
98
        __call = function(self,...)
99
            local s = rawget(self,"_RealService")
100
            if s then return s(...) end
101
        end
102
    }
103
    local function FakeService(t,RealService)
104
        t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
105
        return setmetatable(t,fsmt)
106
    end
107
 
108
    --Fake game object
109
    local g = {
110
        GetService = function(self,s)
111
            return self[s]
112
        end,
113
        Players = FakeService({
114
            LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
115
        },"Players"),
116
        UserInputService = FakeService(UIS,"UserInputService"),
117
        ContextActionService = FakeService(CAS,"ContextActionService"),
118
    }
119
    rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
120
    g.service = g.GetService
121
   
122
    g.RunService = FakeService({
123
        RenderStepped = _rg:GetService("RunService").Heartbeat,
124
        BindToRenderStep = function(self,name,_,fun)
125
            self._btrs[name] = self.Heartbeat:Connect(fun)
126
        end,
127
        UnbindFromRenderStep = function(self,name)
128
            self._btrs[name]:Disconnect()
129
        end,
130
    },"RunService")
131
 
132
    setmetatable(g,{
133
        __index=function(self,s)
134
            return _rg:GetService(s) or typeof(_rg[s])=="function"
135
            and function(_,...)return _rg[s](_rg,...)end or _rg[s]
136
        end,
137
        __newindex = fsmt.__newindex,
138
        __call = fsmt.__call
139
    })
140
    --Changing owner to fake player object to support owner:GetMouse()
141
    game,owner = g,g.Players.LocalPlayer
142
end
143
 
144
 
145
--[[
146
local NetworkAccess = coroutine.create(function()
147
settings().Physics.AllowSleep = false
148
while true do game:GetService("RunService").RenderStepped:Wait()
149
for _,Players in next, game:GetService("Players"):GetChildren() do
150
if Players ~= game:GetService("Players").LocalPlayer then
151
Players.MaximumSimulationRadius = 0.1 Players.SimulationRadius = 0 end end
152
game:GetService("Players").LocalPlayer.MaximumSimulationRadius = math.pow(math.huge,math.huge)
153
game:GetService("Players").LocalPlayer.SimulationRadius = math.huge*math.huge end end)
154
coroutine.resume(NetworkAccess)
155
156
]]
157
158
159
160
plr = owner
161
dead = false
162
char = plr.Character
163
164
gun = char["Black Type-37 Pulse Rifle"]
165
ghandle = gun.Handle
166
ghandle.AccessoryWeld:Destroy()
167
168
bullet = char["Shattered HaloAccessory"]
169
bhandle = bullet.Handle
170
bhandle.SpecialMesh:Destroy()
171
wait()
172
bullet.Parent = workspace
173
174
mouse = plr:GetMouse()
175
head = char.Head
176
camera = workspace.CurrentCamera
177
lt = true
178
ltt = false
179
180
local function IsFirstPerson()
181
     return (head.CFrame.p - camera.CFrame.p).Magnitude < 1
182
end
183
184
     bbv = Instance.new("BodyVelocity",bhandle)
185
186
     rarm = char["Right Arm"]
187
     larm = char["Left Arm"]
188
     torso = char.Torso
189
     
190
     torso["Right Shoulder"]:Destroy()
191
     torso["Left Shoulder"]:Destroy()
192
     
193
     larm.LeftShoulderAttachment:Destroy()
194
     rarm.RightShoulderAttachment:Destroy()
195
     
196
     l = Instance.new("Attachment",larm)
197
     l.Rotation = Vector3.new(-90,20,0)
198
     l.Position = Vector3.new(1,1,0.5)
199
     
200
     r = Instance.new("Attachment",rarm)
201
     r.Rotation = Vector3.new(-90,-25,0)
202
     r.Position = Vector3.new(-1,0.5,0.5)
203
     
204
     t = Instance.new("Attachment",torso)
205
     --rarm
206
     rap = Instance.new("AlignPosition",rarm)
207
     rap.Attachment0 = r
208
     rap.Attachment1 = t
209
     rap.RigidityEnabled = true
210
     
211
     rao = Instance.new("AlignOrientation",rarm)
212
     rao.Attachment0 = r
213
     rao.Attachment1 = t
214
     rao.RigidityEnabled = true
215
     
216
     --larm
217
     
218
     
219
     
220
     
221
     lap = Instance.new("AlignPosition",larm)
222
     lap.Attachment0 = l
223
     lap.Attachment1 = t
224
     lap.RigidityEnabled = true
225
     
226
     lao = Instance.new("AlignOrientation",larm)
227
     lao.Attachment0 = l
228
     lao.Attachment1 = t
229
     lao.RigidityEnabled = true
230
     
231
-- gun
232
233
     h = Instance.new("Attachment",ghandle)
234
     h.Rotation = Vector3.new(-90,130,110)
235
     h.Position = Vector3.new(0.5,0,0.5)
236
     
237
     lg = Instance.new("Attachment",larm)
238
     lg.Rotation = Vector3.new(0,0,0)
239
     lg.Position = Vector3.new(0,0,0)
240
241
     gap = Instance.new("AlignPosition",ghandle)
242
     gap.Attachment0 = h
243
     gap.Attachment1 = lg
244
     gap.RigidityEnabled = true
245
     
246
     gao = Instance.new("AlignOrientation",ghandle)
247
     gao.Attachment0 = h
248
     gao.Attachment1 = lg
249
     gao.RigidityEnabled = true
250
     
251
     
252
     mouse.Button1Down:Connect(function()
253
         if dead == false then
254
        lt = false
255
        ltt = true
256
        
257
        
258
        h.Rotation = Vector3.new(-90,125,115)
259
             
260
        l.Position = Vector3.new(1,0.5,0.5)
261
        l.Rotation = Vector3.new(-95,25,0)
262
        
263
        r.Position = Vector3.new(-1,0,0.5)
264
        r.Rotation = Vector3.new(-95,-33,0)
265
        wait(0.13)
266
                h.Rotation = Vector3.new(-90,130,110)
267
        
268
        l.Position = Vector3.new(1,1,0.5)
269
        l.Rotation = Vector3.new(-90,20,0)
270
        
271
        r.Position = Vector3.new(-1,0.5,0.5)
272
        r.Rotation = Vector3.new(-90,-25,0)
273
        ltt = false
274
             bbav = Instance.new("BodyAngularVelocity",bhandle)
275
     bbav.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
276
     bbav.P = 1000000000000000000000000000
277
     bbav.AngularVelocity = Vector3.new(10000000000000000000000000000000,100000000000000000000000000,100000000000000000)
278
        if game.Players:GetPlayerFromCharacter(mouse.Target.Parent) then
279
              repeat 
280
            game:GetService("RunService").RenderStepped:Wait()
281
            bhandle.Position = mouse.Target.Parent.HumanoidRootPart.CFrame.p
282
            wait(0.23)
283
            until char.Humanoid.Health == 100 or char.Humanoid.Health == 0
284
        elseif game.Players:GetPlayerFromCharacter(mouse.Target.Parent.Parent) then
285
            repeat 
286
            game:GetService("RunService").RenderStepped:Wait()
287
            bhandle.Position = mouse.Target.Parent.Parent.HumanoidRootPart.CFrame.p
288
            wait(0.23)
289
            until char.Humanoid.Health == 100 or char.Humanoid.Health == 0
290
            
291
            else
292
        repeat 
293
        game:GetService("RunService").RenderStepped:Wait()
294
        bhandle.Position = mouse.Hit.p
295
        wait(0.23)
296
        until char.Humanoid.Health == 100 or char.Humanoid.Health == 0
297
        end
298
        wait()
299
        lt = true
300
         end
301
         end)
302
         
303
     char.Humanoid.Died:Connect(function()
304
         dead = true
305
     end)
306
     repeat 
307
         game:GetService("RunService").RenderStepped:Wait()
308
         if dead == false and bhandle.CanCollide == true then
309
         bhandle.CanCollide = false
310
         end
311
         if lt == true and dead == false then
312
         bhandle.CFrame = char.Head.CFrame + Vector3.new(0,-15,0)
313
         elseif ltt == true and dead == false then
314
        bhandle.CFrame = ghandle.CFrame * CFrame.new(-1.7,-2,0)
315
        bhandle.Rotation = char.HumanoidRootPart.Rotation
316
         end
317
    until char.Humanoid.Health == 0