Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- DEFAULT THIRD PERSON PERSPECTIVE --
- local reset = false
- local RunService = game:GetService("RunService")
- -- Variables for the camera and player
- local camera = workspace.CurrentCamera
- local player = game.Players.LocalPlayer
- local disable = false
- local CAMERA_OFFSET = Vector3.new(-1,22,0)
- -- Enables the camera to do what this script says
- camera.CameraType = Enum.CameraType.Scriptable
- -- Called every time the screen refreshes
- local function onRenderStep()
- -- Check the player's character has spawned
- if player.Character then
- local playerPosition = player.Character:WaitForChild("HumanoidRootPart").Position
- local cameraPosition = playerPosition + CAMERA_OFFSET
- -- make the camera follow the player
- camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition)
- end
- end
- RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)
- -- TOGGLE TO FIRST PERSON PERSPECTIVE --
- fp = false
- player.CameraMode = "Classic"
- player.CameraMaxZoomDistance = 22
- player.CameraMinZoomDistance = 22
- local UserInputService = game:GetService("UserInputService")
- UserInputService.InputBegan:Connect(function(input, gameProcessed)
- if input.UserInputType == Enum.UserInputType.MouseButton2 then
- if disable == false then
- if fp == false then
- player.CameraMode = "LockFirstPerson"
- game:GetService("RunService"):UnbindFromRenderStep("Camera")
- game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
- game.Players.LocalPlayer.Character.Humanoid.JumpPower = 0
- fp = true
- elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
- if disable == false then
- if fp then
- RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)
- player.CameraMode = "Classic"
- game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 14
- game.Players.LocalPlayer.Character.Humanoid.JumpPower = 17
- fp = false
- end
- end
- end
- end
- end
- end)
- plr = game:GetService("Players").LocalPlayer
- plr.Character:WaitForChild("Humanoid").Died:Connect(function()
- if fp == true then
- print("fp is true")
- disable = true
- RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)
- player.CameraMode = "Classic"
- plr.CharacterAdded:Wait()
- fp = false
- disable = false
- end
- end)
- plr = game:GetService("Players").LocalPlayer
- plr.Character:WaitForChild("Humanoid").Died:Connect(function()
- if fp == false then
- print("fp = false")
- disable = true
- plr.CharacterAdded:Wait()
- fp = false
- disable = false
- end
- end)
- plr = game:GetService("Players").LocalPlayer
- plr.Character:WaitForChild("Humanoid").Died:Connect(function()
- if fp == true then
- print("fp is true")
- disable = true
- RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)
- player.CameraMode = "Classic"
- plr.CharacterAdded:Wait()
- fp = false
- disable = false
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement