Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local cameraHeight = 12
- local cameraZOffset = 20
- local camera = game.Workspace.CurrentCamera
- local player = game.Players.LocalPlayer
- local function setupCamera()
- camera.CFrame = CFrame.new(Vector3.new(0,cameraHeight,cameraZOffset), Vector3.new(0,cameraHeight,0))
- end
- setupCamera()
- player.CharacterAdded:connect(setupCamera)
- local cameraHeight = 12
- local cameraZOffset = 20
- local cameraXChase = 10
- local cameraSpeed = .25
- local camera = game.Workspace.CurrentCamera
- local player = game.Players.LocalPlayer
- local RunService = game:GetService('RunService')
- local function setupCamera()
- camera.CFrame = CFrame.new(Vector3.new(0,cameraHeight,cameraZOffset),
- Vector3.new(0,cameraHeight,0))
- end
- setupCamera()
- player.CharacterAdded:connect(setupCamera)
- local function onUpdate()
- if player.Character and player.Character:FindFirstChild('Torso') then
- local playerX = player.Character.Torso.Position.X
- local cameraX = camera.CFrame.p.X
- if cameraX - cameraXChase < playerX then
- camera.CFrame = camera.CFrame + Vector3.new(cameraSpeed, 0, 0)
- end
- end
- end
- RunService:BindToRenderStep('Camera', Enum.RenderPriority.Camera.Value, onUpdate)
- local player = game.Players.LocalPlayer
- local RunService = game:GetService('RunService')
- local ContextActionService = game:GetService('ContextActionService')
- local function onLeft(actionName, inputState)
- end
- local function onRight(actionName, inputState)
- end
- local function onJump(actionName, inputState)
- end
- local function onUpdate()
- end
- RunService:BindToRenderStep('Control', Enum.RenderPriority.Input.Value, onUpdate)
- ContextActionService:BindAction('Left', onLeft, true, 'a', Enum.KeyCode.Left, Enum.KeyCode.DPadLeft)
- ContextActionService:BindAction('Right', onRight, true, 'd', Enum.KeyCode.Right, Enum.KeyCode.DPadRight)
- ContextActionService:BindAction('Jump', onJump, true, 'w', Enum.KeyCode.Space, Enum.KeyCode.Up, Enum.KeyCode.DPadUp, Enum.KeyCode.ButtonA)
- local player = game.Players.LocalPlayer
- local RunService = game:GetService('RunService')
- local ContextActionService = game:GetService('ContextActionService')
- local jumping = false
- local leftValue, rightValue = 0, 0
- local function onLeft(actionName, inputState)
- if inputState == Enum.UserInputState.Begin then
- leftValue = 1
- elseif inputState == Enum.UserInputState.End then
- leftValue = 0
- end
- end
- local function onRight(actionName, inputState)
- if inputState == Enum.UserInputState.Begin then
- rightValue = 1
- elseif inputState == Enum.UserInputState.End then
- rightValue = 0
- end
- end
- local function onJump(actionName, inputState)
- if inputState == Enum.UserInputState.Begin then
- jumping = true
- elseif inputState == Enum.UserInputState.End then
- jumping = false
- end
- end
- local function onUpdate()
- if player.Character and player.Character:FindFirstChild('Humanoid') then
- if jumping then
- player.Character.Humanoid.Jump = true
- end
- local moveDirection = rightValue - leftValue
- player.Character.Humanoid:Move(Vector3.new(moveDirection,0,0), false)
- end
- end
Add Comment
Please, Sign In to add comment