Can anyone help me with this camera changing thing?
Asked by
8 years ago Edited 8 years ago
Here is a section of code. I need the game to be able to figure out if the player is either walking or climbing, but I don't really know what to put there. Please help.
01 | local player = game.Players.LocalPlayer |
05 | player.AutoJumpEnabled = false |
07 | if walking = false and climbing = false then |
08 | player.CameraMode = LockFirstPesron |
12 | player.CameraMode = Classic |
Also here is the rest of the code for reference.
Flying (Camera Change)
01 | local player = game.Players.LocalPlayer |
04 | number = script.Parent.Camera.di.Value |
18 | player.AutoJumpEnabled = false |
22 | if walking = = false then |
23 | if climbing = = false then |
24 | player.CameraMode = Enum.CameraMode.LockFirstPerson |
29 | player.CameraMode = Enum.CameraMode.Classic |
Camera
03 | local offset = Vector 3. new(y,y,y) |
07 | local player = game.Players.LocalPlayer |
08 | local camera = game.Workspace.CurrentCamera |
09 | local runService = game:GetService( 'RunService' ) |
10 | local character = player.Character or player.CharacterAdded:wait() |
12 | camera.FieldOfView = fieldOfView |
14 | local function onRenderStep() |
15 | local playerPosition = character.Head.Position |
16 | local cameraPosition = playerPosition + offset |
17 | camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition) |
20 | runService:BindToRenderStep( 'Camera' , Enum.RenderPriority.Camera.Value, onRenderStep) |
Controls
01 | local player = game.Players.LocalPlayer |
03 | local mouse = player:GetMouse() |
04 | mouse.TargetFilter = game.Workspace.Level |
05 | local runService = game:GetService( 'RunService' ) |
06 | local character = player.Character or player.CharacterAdded:wait() |
08 | local function onCharacterAdded(character) |
09 | local head = character:WaitForChild( 'Head' ) |
10 | gyro = Instance.new( 'BodyGyro' ) |
12 | gyro.MaxTorque = Vector 3. new( 0 , 10000 , 0 ) |
15 | local humanoid = character:WaitForChild( 'Humanoid' ) |
16 | humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false ) |
17 | humanoid:SetStateEnabled(Enum.HumanoidStateType.Climbing, true ) |
20 | local function isnan(x) return x ~ = x end |
22 | local function onRenderStep() |
24 | local mouseHit = mouse.Hit.p |
25 | if not (isnan(mouseHit.X) or isnan(mouseHit.Y) or isnan(mouseHit.Z)) then |
26 | gyro.CFrame = CFrame.new(character.Head.Position, mouseHit) |
31 | while not player.Character do wait() end |
32 | onCharacterAdded(player.Character) |
33 | player.CharacterAdded:connect(onCharacterAdded) |
35 | runService:BindToRenderStep( 'TrackMouse' , Enum.RenderPriority.Input.Value, onRenderStep) |