Files
Roblox-Elevator-Game/src/client/Player/init.client.lua
2023-12-29 03:16:39 -05:00

52 lines
1.6 KiB
Lua

local UI = script:WaitForChild("UI")
local CrosshairSettings = require(UI:WaitForChild("Crosshair"))
local VignetteSettings = require(UI:WaitForChild("Vignette"))
local CoreGuis = require(script:WaitForChild("CoreGuis"))
local Mouse = require(script:WaitForChild("Mouse"))
local Players = game:GetService("Players")
local Storage = game:GetService("ReplicatedStorage")
local ClientStorage = Storage:WaitForChild("Client")
local LoadCompleted = ClientStorage:WaitForChild("LoadingComplete")
local KeyBindsModule = require(ClientStorage:WaitForChild("KeyBinds"))
local CameraSettings = require(ClientStorage:WaitForChild("Camera"))
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
CoreGuis:Off()
--We need to wait for the game to load before spamming functionality
repeat
local GameIsLoaded = LoadCompleted:Invoke()
task.wait()
until GameIsLoaded
local CurrentCamera = nil
repeat
task.wait()
CurrentCamera = workspace.CurrentCamera
until CurrentCamera
local Vignette = VignetteSettings.constructor(PlayerGui)
local Camera = CameraSettings.constructor(CurrentCamera, Player)
local Crosshair = CrosshairSettings.constructor(PlayerGui)
--Keybinds
local function CameraBinds()
local CameraBindMap = KeyBindsModule.constructor()
CameraBindMap:AddInputBegan({Enum.KeyCode.C, Enum.KeyCode.Z}, function()
Camera:ZoomIn(Vignette, Crosshair)
end)
CameraBindMap:AddInputEnded({Enum.KeyCode.C, Enum.KeyCode.Z}, function()
Camera:ZoomOut(Vignette, Crosshair)
end)
end
Camera:FirstPerson()
Mouse:DisablePointer()
Crosshair:Enable()
CameraBinds()