Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --TODO: add comments or something idk
- if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
- local Player = owner
- local Mouse,mouse,UserInputService,ContextActionService
- do
- script.Parent = Player.Character
- local CAS = {Actions={}}
- local Event = Instance.new("RemoteEvent")
- Event.Name = "UserInput_Event"
- Event.Parent = Player.Character
- local fakeEvent = function()
- local t = {_fakeEvent=true}
- t.Connect = function(self,f)self.Function=f end
- t.connect = t.Connect
- return t
- end
- local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
- local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
- function CAS:BindAction(name,fun,touch,...)
- CAS.Actions[name] = {Name=name,Function=fun,Keys={...}}
- end
- function CAS:UnbindAction(name)
- CAS.Actions[name] = nil
- end
- local function te(self,ev,...)
- local t = m[ev]
- if t and t._fakeEvent and t.Function then
- t.Function(...)
- end
- end
- m.TrigEvent = te
- UIS.TrigEvent = te
- Event.OnServerEvent:Connect(function(plr,io)
- if plr~=Player then return end
- if io.isMouse then
- m.Target = io.Target
- m.Hit = io.Hit
- elseif io.UserInputType == Enum.UserInputType.MouseButton1 then
- if io.UserInputState == Enum.UserInputState.Begin then
- m:TrigEvent("Button1Down")
- else
- m:TrigEvent("Button1Up")
- end
- else
- for n,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
- if io.UserInputState == Enum.UserInputState.Begin then
- m:TrigEvent("KeyDown",io.KeyCode.Name:lower())
- UIS:TrigEvent("InputBegan",io,false)
- else
- m:TrigEvent("KeyUp",io.KeyCode.Name:lower())
- UIS:TrigEvent("InputEnded",io,false)
- end
- end
- end)
- NLS([==[
- local Player = game:GetService("Players").LocalPlayer
- local Char = Player.Character
- local Event = Char:WaitForChild("UserInput_Event")
- local UIS = game:GetService("UserInputService")
- local input = function(io,a)
- if a then return end
- local io = {KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState}
- Event:FireServer(io)
- end
- UIS.InputBegan:Connect(input)
- UIS.InputEnded:Connect(input)
- local Changed = false
- local Mouse = Player:GetMouse()
- local mouse = Player:GetMouse()
- local h,t = Mouse.Hit,Mouse.Target
- while wait(1/30) do
- if h~=Mouse.Hit or t~=Mouse.Target then
- Event:FireServer({isMouse=true,Target=Mouse.Target,Hit=Mouse.Hit})
- h,t=Mouse.Hit,Mouse.Target
- end
- end
- ]==],Player.Character)
- Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
- end
- ---
- Player = owner
- PlayerGui = Player.PlayerGui
- Cam = workspace.CurrentCamera
- Backpack = Player.Backpack
- Character = Player.Character
- Humanoid = Character.Humanoid
- wait(0.2)
- --[[
- Thanks for using Build-To-Lua by jarredbcv.
- ]]--
- New = function(Object, Parent, Name, Data)
- local Object = Instance.new(Object)
- for Index, Value in pairs(Data or {}) do
- Object[Index] = Value
- end
- Object.Parent = Parent
- Object.Name = Name
- return Object
- end
- Char = New("Part",Workspace,"Char",{BrickColor = BrickColor.new("Alder"),Material = Enum.Material.SmoothPlastic,Size = Vector3.new(3.96000004, 3.8199985, 4.09999466),CFrame = CFrame.new(-6.14301682, 1.91000998, -11.4384756, 1, 0, 0, 0, 1, 0, 0, 0, 1),BottomSurface = Enum.SurfaceType.Smooth,TopSurface = Enum.SurfaceType.Smooth,Color = Color3.new(0.705882, 0.501961, 1),})
- Decal = New("Decal",Char,"Decal",{Face = Enum.NormalId.Back,Texture = "rbxassetid://802372527",})
- Mesh = New("SpecialMesh",Char,"Mesh",{MeshType = Enum.MeshType.Sphere,})
- BodyForce = New("BodyForce",Char,"BodyForce",{})
- wait()
- function sandbox(var,func)
- local env = getfenv(func)
- local newenv = setmetatable({},{
- __index = function(self,k)
- if k=="script" then
- return var
- else
- return env[k]
- end
- end,
- })
- setfenv(func,newenv)
- return func
- end
- cors = {}
- mas = Instance.new("Model",game:GetService("Lighting"))
- StarterPlayerScripts0 = Instance.new("StarterPlayerScripts")
- LocalScript1 = Instance.new("LocalScript")
- StarterCharacterScripts2 = Instance.new("StarterCharacterScripts")
- LocalScript3 = Instance.new("LocalScript")
- StarterPlayerScripts0.Parent = mas
- LocalScript1.Name = "Todd"
- LocalScript1.Parent = StarterPlayerScripts0
- table.insert(cors,sandbox(LocalScript1,function()
- char = workspace.Char
- w, a, s, d = 0,0,0,0
- game:GetService("UserInputService").InputBegan:connect(function(k)
- k = k.KeyCode.Name
- if k == "W" then
- w = 1
- elseif k == "A" then
- a = 1
- elseif k == "S" then
- s = 1
- elseif k == "D" then
- d = 1
- elseif k == "Space" then
- jump()
- end
- end)
- game:GetService("UserInputService").InputEnded:connect(function(k)
- k = k.KeyCode.Name
- if k == "W" then
- w = 0
- elseif k == "A" then
- a = 0
- elseif k == "S" then
- s = 0
- elseif k == "D" then
- d = 0
- end
- end)
- function jump()
- if ground and not jumping then
- jumping = true
- char.Velocity = v2(char.Velocity, 30)
- wait(.3)
- jumping = false
- end
- end
- function v2(v3, b)
- return Vector3.new(v3.X, b or 0, v3.Z)
- end
- wait()
- workspace.CurrentCamera.CameraType = "Scriptable"
- ignore = {char}
- ground = false
- jumping = false
- end))
- StarterCharacterScripts2.Parent = mas
- LocalScript3.Parent = StarterCharacterScripts2
- for i,v in pairs(mas:GetChildren()) do
- v.Parent = workspace
- pcall(function() v:MakeJoints() end)
- end
- mas:Destroy()
- for i,v in pairs(cors) do
- spawn(function()
- pcall(v)
- end)
- end
- StarterPlayerScripts0 = Instance.new("StarterPlayerScripts")
- StarterCharacterScripts2 = Instance.new("StarterCharacterScripts")
- StarterPlayerScripts0.Parent = game
- StarterCharacterScripts2.Parent = game
- while wait(0.5) do
- wait(0.5)
- New = function(Object, Parent, Name, Data)
- local Object = Instance.new(Object)
- for Index, Value in pairs(Data or {}) do
- Object[Index] = Value
- end
- Object.Parent = Parent
- Object.Name = Name
- return Object
- end
- Char = New("Part",Workspace,"Char",{BrickColor = BrickColor.new("Alder"),Material = Enum.Material.SmoothPlastic,Size = Vector3.new(3.96000004, 3.8199985, 4.09999466),CFrame = CFrame.new(-6.14301682, 1.91000998, -11.4384756, 1, 0, 0, 0, 1, 0, 0, 0, 1),BottomSurface = Enum.SurfaceType.Smooth,TopSurface = Enum.SurfaceType.Smooth,Color = Color3.new(0.705882, 0.501961, 1),})
- Decal = New("Decal",Char,"Decal",{Face = Enum.NormalId.Back,Texture = "rbxassetid://802372527",})
- Mesh = New("SpecialMesh",Char,"Mesh",{MeshType = Enum.MeshType.Sphere,})
- BodyForce = New("BodyForce",Char,"BodyForce",{})
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement