112 lines
3.9 KiB
Luau
112 lines
3.9 KiB
Luau
--!strict
|
|
local Text = require(game:GetService("ReplicatedStorage"):WaitForChild("Hunter"):WaitForChild("Strings") :: ModuleScript).interface.LobbyCamera
|
|
|
|
-- V toggles the lobby camera. Arena entry always selects first person.
|
|
|
|
local Players = game:GetService("Players")
|
|
local RunService = game:GetService("RunService")
|
|
local StarterGui = game:GetService("StarterGui")
|
|
local UserInputService = game:GetService("UserInputService")
|
|
|
|
local player = Players.LocalPlayer
|
|
local config = player:WaitForChild("PlayerScripts"):WaitForChild("SniperViewmodel")
|
|
local lobbyThirdPerson = true
|
|
|
|
local respawnGui = Instance.new("ScreenGui")
|
|
respawnGui.Name = "RespawnScreen"
|
|
respawnGui.ResetOnSpawn = false
|
|
respawnGui.DisplayOrder = 1000
|
|
respawnGui.ScreenInsets = Enum.ScreenInsets.None
|
|
respawnGui.Enabled = false
|
|
respawnGui.Parent = player:WaitForChild("PlayerGui")
|
|
|
|
local cover = Instance.new("Frame")
|
|
cover.Name = "Cover"
|
|
cover.Size = UDim2.fromScale(1, 1)
|
|
cover.BackgroundColor3 = Color3.fromRGB(10, 16, 28)
|
|
cover.BorderSizePixel = 0
|
|
cover.Active = true
|
|
cover.Parent = respawnGui
|
|
|
|
local message = Instance.new("TextLabel")
|
|
message.AnchorPoint = Vector2.new(.5, .5)
|
|
message.Position = UDim2.fromScale(.5, .5)
|
|
message.Size = UDim2.new(1, -32, 0, 38)
|
|
message.BackgroundTransparency = 1
|
|
message.Font = Enum.Font.GothamBold
|
|
message.Text = Text.vozrozhdenie
|
|
message.TextSize = 24
|
|
message.TextColor3 = Color3.fromRGB(240, 244, 255)
|
|
message.Parent = cover
|
|
|
|
local deathConnection: RBXScriptConnection? = nil
|
|
|
|
local function conceal()
|
|
respawnGui.Enabled = true
|
|
local camera = workspace.CurrentCamera
|
|
if camera then camera.CameraType = Enum.CameraType.Scriptable end
|
|
end
|
|
|
|
local function followCharacter(character: Model)
|
|
local humanoid = character:WaitForChild("Humanoid", 10)
|
|
if not humanoid or not humanoid:IsA("Humanoid") or player.Character ~= character then return end
|
|
if deathConnection then deathConnection:Disconnect() end
|
|
deathConnection = humanoid.Died:Connect(function()
|
|
if player.Character == character then conceal() end
|
|
end)
|
|
if humanoid.Health <= 0 then
|
|
conceal()
|
|
return
|
|
end
|
|
if not respawnGui.Enabled then return end
|
|
|
|
local root = character:WaitForChild("HumanoidRootPart", 10)
|
|
if not root or player.Character ~= character or humanoid.Health <= 0 then return end
|
|
local camera = workspace.CurrentCamera
|
|
if camera then
|
|
camera.CameraSubject = humanoid
|
|
camera.CameraType = Enum.CameraType.Custom
|
|
end
|
|
-- Keep the cover in place until the camera has rendered from the new character.
|
|
RunService.RenderStepped:Wait()
|
|
RunService.RenderStepped:Wait()
|
|
if player.Character == character and humanoid.Health > 0 then respawnGui.Enabled = false end
|
|
end
|
|
|
|
player.CharacterRemoving:Connect(function()
|
|
if deathConnection then deathConnection:Disconnect() deathConnection = nil end
|
|
if player:GetAttribute("InArena") == true then conceal() end
|
|
end)
|
|
player.CharacterAdded:Connect(followCharacter)
|
|
if player.Character then task.spawn(followCharacter, player.Character) end
|
|
|
|
local function applyView(thirdPerson: boolean)
|
|
config:SetAttribute("ThirdPersonView", thirdPerson)
|
|
player.CameraMode = if thirdPerson then Enum.CameraMode.Classic else Enum.CameraMode.LockFirstPerson
|
|
if thirdPerson then
|
|
player.CameraMaxZoomDistance = 128
|
|
player.CameraMinZoomDistance = 3
|
|
else
|
|
player.CameraMinZoomDistance = 0.5
|
|
player.CameraMaxZoomDistance = 0.5
|
|
end
|
|
end
|
|
|
|
local function applyZone()
|
|
local inArena = player:GetAttribute("InArena") == true
|
|
applyView(not inArena and lobbyThirdPerson)
|
|
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
|
|
end
|
|
player:GetAttributeChangedSignal("InArena"):Connect(applyZone)
|
|
applyZone()
|
|
|
|
UserInputService.InputBegan:Connect(function(input: InputObject, processed: boolean)
|
|
if processed or respawnGui.Enabled or UserInputService:GetFocusedTextBox() then
|
|
return
|
|
end
|
|
if input.KeyCode == Enum.KeyCode.V and player:GetAttribute("InArena") ~= true then
|
|
lobbyThirdPerson = config:GetAttribute("ThirdPersonView") ~= true
|
|
applyView(lobbyThirdPerson)
|
|
end
|
|
end)
|