View difference between Paste ID: wU4SVYg8 and LnYpMVUJ
SHOW: | | - or go back to the newest paste.
1
--just put this on the top of a script and boom 89% works
2
--note this does not work on big scripts
3
if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
4
local Player,game,owner = owner,game
5
local RealPlayer = Player
6
do
7
    local rp = RealPlayer
8
    script.Parent = rp.Character
9
   
10
    --RemoteEvent for communicating
11
    local Event = Instance.new("RemoteEvent")
12
    Event.Name = "UserInput_Event"
13
 
14
    --Fake event to make stuff like Mouse.KeyDown work
15
    local function fakeEvent()
16
        local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
17
        t.connect = t.Connect
18
        return t
19
    end
20
 
21
    --Creating fake input objects with fake variables
22
    local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
23
    local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
24
    local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
25
        CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
26
    end}
27
    --Merged 2 functions into one by checking amount of arguments
28
    CAS.UnbindAction = CAS.BindAction
29
 
30
    --This function will trigger the events that have been :Connect()'ed
31
    local function te(self,ev,...)
32
        local t = m[ev]
33
        if t and t._fakeEvent then
34
            for _,f in pairs(t.Functions) do
35
                f(...)
36
            end
37
        end
38
    end
39
    m.TrigEvent = te
40
    UIS.TrigEvent = te
41
 
42
    Event.OnServerEvent:Connect(function(plr,io)
43
        if plr~=rp then return end
44
        m.Target = io.Target
45
        m.Hit = io.Hit
46
        if not io.isMouse then
47
            local b = io.UserInputState == Enum.UserInputState.Begin
48
            if io.UserInputType == Enum.UserInputType.MouseButton1 then
49
                return m:TrigEvent(b and "Button1Down" or "Button1Up")
50
            end
51
            for _,t in pairs(CAS.Actions) do
52
                for _,k in pairs(t.Keys) do
53
                    if k==io.KeyCode then
54
                        t.Function(t.Name,io.UserInputState,io)
55
                    end
56
                end
57
            end
58
            m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
59
            UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
60
        end
61
    end)
62
    Event.Parent = NLS([==[
63
    local Player = game:GetService("Players").LocalPlayer
64
    local Event = script:WaitForChild("UserInput_Event")
65
 
66
    local Mouse = Player:GetMouse()
67
    local UIS = game:GetService("UserInputService")
68
    local input = function(io,a)
69
        if a then return end
70
        --Since InputObject is a client-side instance, we create and pass table instead
71
        Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
72
    end
73
    UIS.InputBegan:Connect(input)
74
    UIS.InputEnded:Connect(input)
75
 
76
    local h,t
77
    --Give the server mouse data 30 times every second, but only if the values changed
78
    --If player is not moving their mouse, client won't fire events
79
    while wait(1/30) do
80
        if h~=Mouse.Hit or t~=Mouse.Target then
81
            h,t=Mouse.Hit,Mouse.Target
82
            Event:FireServer({isMouse=true,Target=t,Hit=h})
83
        end
84
    end]==],Player.Character)
85
 
86
    ----Sandboxed game object that allows the usage of client-side methods and services
87
    --Real game object
88
    local _rg = game
89
 
90
    --Metatable for fake service
91
    local fsmt = {
92
        __index = function(self,k)
93
            local s = rawget(self,"_RealService")
94
            if s then return s[k] end
95
        end,
96
        __newindex = function(self,k,v)
97
            local s = rawget(self,"_RealService")
98
            if s then s[k]=v end
99
        end,
100
        __call = function(self,...)
101
            local s = rawget(self,"_RealService")
102
            if s then return s(...) end
103
        end
104
    }
105
    local function FakeService(t,RealService)
106
        t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
107
        return setmetatable(t,fsmt)
108
    end
109
 
110
    --Fake game object
111
    local g = {
112
        GetService = function(self,s)
113
            return self[s]
114
        end,
115
        Players = FakeService({
116
            LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
117
        },"Players"),
118
        UserInputService = FakeService(UIS,"UserInputService"),
119
        ContextActionService = FakeService(CAS,"ContextActionService"),
120
    }
121
    rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
122
    g.service = g.GetService
123
   
124
    g.RunService = FakeService({
125
        RenderStepped = _rg:GetService("RunService").Heartbeat,
126
        BindToRenderStep = function(self,name,_,fun)
127
            self._btrs[name] = self.Heartbeat:Connect(fun)
128
        end,
129
        UnbindFromRenderStep = function(self,name)
130
            self._btrs[name]:Disconnect()
131
        end,
132
    },"RunService")
133
 
134
    setmetatable(g,{
135
        __index=function(self,s)
136
            return _rg:GetService(s) or typeof(_rg[s])=="function"
137
            and function(_,...)return _rg[s](_rg,...)end or _rg[s]
138
        end,
139
        __newindex = fsmt.__newindex,
140
        __call = fsmt.__call
141
    })
142
    --Changing owner to fake player object to support owner:GetMouse()
143
    game,owner = g,g.Players.LocalPlayer
144
end
145
 
146
147
--By Rufus14
148
mouse = game.Players.LocalPlayer:GetMouse()
149
rig = game.Players.LocalPlayer.Character.Torso
150
game.Players.LocalPlayer.Character.Animate:destroy()
151
run = Instance.new("Sound", game.Players.LocalPlayer.Character.Head)
152
run.SoundId = "rbxassetid://142665235"
153
run.Volume = 0
154
run.Looped = true
155
run:Play()
156
run.PlaybackSpeed = 1.2
157
print(rig["Left Hip"].C0)
158
print(rig["Right Hip"].C0)
159
cart = Instance.new("Part", rig)
160
cart.CanCollide = false
161
weld = Instance.new("Weld", cart)
162
weld.Part0 = cart
163
weld.Part1 = rig
164
mesh = Instance.new("SpecialMesh", cart)
165
mesh.MeshId = "rbxassetid://552693518"
166
mesh.TextureId = "rbxassetid://552693524"
167
mesh.Scale = Vector3.new(7.2,7,8)
168
weld.C0 = weld.C0 * CFrame.new(0,1,4.2)
169
walking = true
170
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 25
171
for i = 1,20 do
172
    wait()
173
    rig["Left Shoulder"].C0 = rig["Left Shoulder"].C0 * CFrame.Angles(0,0,-0.08)
174
    rig["Right Shoulder"].C0 = rig["Right Shoulder"].C0 * CFrame.Angles(0,0,0.08)
175
end
176
function walk(key)
177
    key = key:lower()
178
    if key == "w" then
179
    walking = true
180
    run.Volume = 10
181
    if walking == true then
182
    wait()
183
    for i = 1,5 do
184
    rig["Left Hip"].C0 = rig["Left Hip"].C0 * CFrame.Angles(0,0,-0.2)
185
    rig["Right Hip"].C0 = rig["Right Hip"].C0 * CFrame.Angles(0,0,-0.2)
186
    end
187
    while walking == true do
188
    for i = 1,5 do
189
    wait()
190
    rig["Left Hip"].C0 = rig["Left Hip"].C0 * CFrame.Angles(0,0,0.4)
191
    rig["Right Hip"].C0 = rig["Right Hip"].C0 * CFrame.Angles(0,0,0.4)
192
    end
193
    for i = 1,5 do
194
    wait()
195
    rig["Left Hip"].C0 = rig["Left Hip"].C0 * CFrame.Angles(0,0,-0.4)
196
    rig["Right Hip"].C0 = rig["Right Hip"].C0 * CFrame.Angles(0,0,-0.4)
197
    end
198
    end
199
    end
200
    end
201
    end
202
mouse.KeyDown:connect(walk)
203
function notwalk(key)
204
    key = key:lower()
205
    if key == "w" then
206
        walking = false
207
        run.Volume = 0
208
        for i = 1,10 do
209
        wait()
210
        rig["Left Hip"].C0 = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
211
        rig["Right Hip"].C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
212
        end
213
    end
214
end
215
mouse.KeyUp:connect(notwalk)
216
---------------------------------
217
walking1 = false
218
function walk1(key)
219
    key = key:lower()
220
    if key == "d" then
221
    walking1 = true
222
    if walking1 == true then
223
    wait()
224
    run.Volume = 10
225
    for i = 1,5 do
226
    rig["Left Hip"].C0 = rig["Left Hip"].C0 * CFrame.Angles(0,0,-0.2)
227
    rig["Right Hip"].C0 = rig["Right Hip"].C0 * CFrame.Angles(0,0,-0.2)
228
    end
229
    while walking1 == true do
230
    for i = 1,5 do
231
    wait()
232
    rig["Left Hip"].C0 = rig["Left Hip"].C0 * CFrame.Angles(0,0,0.4)
233
    rig["Right Hip"].C0 = rig["Right Hip"].C0 * CFrame.Angles(0,0,0.4)
234
    end
235
    for i = 1,5 do
236
    wait()
237
    rig["Left Hip"].C0 = rig["Left Hip"].C0 * CFrame.Angles(0,0,-0.4)
238
    rig["Right Hip"].C0 = rig["Right Hip"].C0 * CFrame.Angles(0,0,-0.4)
239
    end
240
    end
241
    end
242
    end
243
    end
244
mouse.KeyDown:connect(walk1)
245
function notwalk1(key)
246
    key = key:lower()
247
    if key == "d" then
248
        walking1 = false
249
        run.Volume = 0
250
        for i = 1,10 do
251
        wait()
252
        rig["Left Hip"].C0 = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
253
        rig["Right Hip"].C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
254
        end
255
    end
256
end
257
mouse.KeyUp:connect(notwalk1)
258
------------------------------------------
259
walking2 = false
260
function walk2(key)
261
    key = key:lower()
262
    if key == "a" then
263
    walking2 = true
264
    run.Volume = 10
265
    if walking2 == true then
266
    wait()
267
    for i = 1,5 do
268
    rig["Left Hip"].C0 = rig["Left Hip"].C0 * CFrame.Angles(0,0,-0.2)
269
    rig["Right Hip"].C0 = rig["Right Hip"].C0 * CFrame.Angles(0,0,-0.2)
270
    end
271
    while walking2 == true do
272
    for i = 1,5 do
273
    wait()
274
    rig["Left Hip"].C0 = rig["Left Hip"].C0 * CFrame.Angles(0,0,0.4)
275
    rig["Right Hip"].C0 = rig["Right Hip"].C0 * CFrame.Angles(0,0,0.4)
276
    end
277
    for i = 1,5 do
278
    wait()
279
    rig["Left Hip"].C0 = rig["Left Hip"].C0 * CFrame.Angles(0,0,-0.4)
280
    rig["Right Hip"].C0 = rig["Right Hip"].C0 * CFrame.Angles(0,0,-0.4)
281
    end
282
    end
283
    end
284
    end
285
    end
286
mouse.KeyDown:connect(walk2)
287
function notwalk2(key)
288
    key = key:lower()
289
    if key == "a" then
290
        walking2 = false
291
        run.Volume = 0
292
        for i = 1,10 do
293
        wait()
294
        rig["Left Hip"].C0 = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
295
        rig["Right Hip"].C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
296
        end
297
    end
298
end
299
mouse.KeyUp:connect(notwalk2)
300
----------------------------------------------------
301
walking3 = false
302
function walk3(key)
303
    key = key:lower()
304
    if key == "s" then
305
    walking3 = true
306
    run.Volume = 10
307
    if walking3 == true then
308
    wait()
309
    for i = 1,5 do
310
    rig["Left Hip"].C0 = rig["Left Hip"].C0 * CFrame.Angles(0,0,-0.2)
311
    rig["Right Hip"].C0 = rig["Right Hip"].C0 * CFrame.Angles(0,0,-0.2)
312
    end
313
    while walking3 == true do
314
    for i = 1,5 do
315
    wait()
316
    rig["Left Hip"].C0 = rig["Left Hip"].C0 * CFrame.Angles(0,0,0.4)
317
    rig["Right Hip"].C0 = rig["Right Hip"].C0 * CFrame.Angles(0,0,0.4)
318
    end
319
    for i = 1,5 do
320
    wait()
321
    rig["Left Hip"].C0 = rig["Left Hip"].C0 * CFrame.Angles(0,0,-0.4)
322
    rig["Right Hip"].C0 = rig["Right Hip"].C0 * CFrame.Angles(0,0,-0.4)
323
    end
324
    end
325
    end
326
    end
327
    end
328
mouse.KeyDown:connect(walk3)
329
function notwalk3(key)
330
    key = key:lower()
331
    if key == "s" then
332
        walking3 = false
333
        run.Volume = 0
334
        for i = 1,10 do
335
        wait()
336
        rig["Left Hip"].C0 = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
337
        rig["Right Hip"].C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
338
        end
339
    end
340
end
341
mouse.KeyUp:connect(notwalk3)
342
grabbing = true
343
function grab1(cart1)
344
        if grabbing == true then
345
        local torso = cart1.Parent:findFirstChild("Torso")
346
                if torso ~= nil then
347
                local hum = cart1.Parent:findFirstChild("Humanoid")
348
                if hum ~= nil then
349
                hum.PlatformStand = true
350
        local weld1 = Instance.new("Weld", torso)
351
        weld1.Part0 = torso
352
        weld1.Part1 = cart
353
        weld1.C0 = weld1.C0 * CFrame.Angles(-8,0,1.2) * CFrame.new(0,-1.4,0)
354
                end
355
                end
356
    end
357
    end
358
cart.Touched:connect(grab1)