mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
92 lines
2.7 KiB
Lua
92 lines
2.7 KiB
Lua
--!optimize 2
|
|
--!native
|
|
--!strict
|
|
|
|
type CurrentCamera = Camera
|
|
|
|
local Players = game:GetService("Players")
|
|
local Storage = game:GetService("ReplicatedStorage")
|
|
local RS = game:GetService("RunService")
|
|
|
|
--Production--
|
|
if not RS:IsStudio() then
|
|
task.wait()
|
|
script.Parent.Parent = nil
|
|
end
|
|
--
|
|
|
|
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 Character = require(script:WaitForChild("Character"))
|
|
|
|
local function LoadCharacter(CharacterModel)
|
|
local CharacterConstructor = Character.constructor(CharacterModel)
|
|
|
|
CharacterConstructor:DisableRobloxSounds()
|
|
CharacterConstructor:SetWalkSpeed()
|
|
CharacterConstructor:SetJumpHeight()
|
|
CharacterConstructor:Crosshair()
|
|
CharacterConstructor:EnableCameraBobbing()
|
|
CharacterConstructor:CharacterKeyBinds()
|
|
end
|
|
|
|
--We need to wait for the game to load before spamming functionality
|
|
repeat
|
|
local GameIsLoaded = game:IsLoaded()
|
|
task.wait()
|
|
until GameIsLoaded
|
|
|
|
local CurrentCamera: CurrentCamera
|
|
repeat
|
|
task.wait()
|
|
CurrentCamera = workspace.CurrentCamera
|
|
until CurrentCamera
|
|
|
|
local ClientStorage = Storage:WaitForChild("Client")
|
|
local KeyBindsModule = require(ClientStorage:WaitForChild("KeyBinds"))
|
|
local CameraSettings = require(ClientStorage:WaitForChild("Camera"))
|
|
|
|
local Player = Players.LocalPlayer
|
|
local PlayerGui = Player:WaitForChild("PlayerGui") :: PlayerGui
|
|
local PlayerCharacter = Player.Character or Player.CharacterAdded:Wait()
|
|
|
|
local Vignette = VignetteSettings.constructor(PlayerGui)
|
|
local Camera = CameraSettings.constructor(CurrentCamera, Player)
|
|
local Crosshair = CrosshairSettings.constructor(PlayerGui)
|
|
|
|
--Keybinds
|
|
local function CameraBinds()
|
|
local CameraBindMap = KeyBindsModule.constructor(false)
|
|
|
|
CameraBindMap:AddInputBegan({Enum.KeyCode.C, Enum.KeyCode.Z}, function(_KeyPressed)
|
|
Camera:ZoomIn(Vignette, Crosshair)
|
|
end)
|
|
CameraBindMap:AddInputEnded({Enum.KeyCode.C, Enum.KeyCode.Z}, function(_KeyPressed)
|
|
Camera:ZoomOut(Vignette, Crosshair)
|
|
end)
|
|
end
|
|
|
|
local function Crosshair3DEffect()
|
|
local RootVelocity = Instance.new("BindableEvent") :: BindableEvent
|
|
RootVelocity.Name = "RootVelocity"
|
|
RootVelocity.Parent = ClientStorage
|
|
|
|
RootVelocity.Event:Connect(function(RootVelocity: Vector3)
|
|
Crosshair:Jump(RootVelocity)
|
|
end)
|
|
end
|
|
|
|
CoreGuis:Off()
|
|
Camera:FirstPerson()
|
|
Mouse:DisablePointer()
|
|
Crosshair:Enable()
|
|
|
|
CameraBinds()
|
|
Crosshair3DEffect()
|
|
|
|
LoadCharacter(PlayerCharacter)
|
|
Player.CharacterAdded:Connect(LoadCharacter)
|