Loading gui work, needs finished

This commit is contained in:
2023-12-28 02:40:00 -05:00
parent e55b8763f3
commit c3069d11f9
9 changed files with 273 additions and 20 deletions

View File

@@ -1,6 +1,8 @@
local CrouchModule = {
StandHeight = 2.1,
CrouchHeight = .6
CrouchHeight = .6,
WalkSpeedMultiplier = 6,
CrouchSpeed = .2
}
CrouchModule.__index = CrouchModule
@@ -15,17 +17,21 @@ end
local CrouchTween = Tween.constructor()
function CrouchModule:Crouch(StandingWalkSpeed: number)
local Easing = TweenInfo.new(CrouchModule.CrouchSpeed, Enum.EasingStyle.Linear)
CrouchTween:Start(self.Humanoid, {
HipHeight = CrouchModule.CrouchHeight,
WalkSpeed = StandingWalkSpeed-6
}, TweenInfo.new(.4))
WalkSpeed = math.max(1, StandingWalkSpeed-CrouchModule.WalkSpeedMultiplier)
}, Easing)
end
function CrouchModule:Stand(CrouchingWalkSpeed: number)
local Easing = TweenInfo.new(CrouchModule.CrouchSpeed, Enum.EasingStyle.Linear)
CrouchTween:Start(self.Humanoid, {
HipHeight = CrouchModule.StandHeight,
WalkSpeed = CrouchingWalkSpeed+6
}, TweenInfo.new(.2))
WalkSpeed = math.max(1, CrouchingWalkSpeed+CrouchModule.WalkSpeedMultiplier)
}, Easing)
end
return CrouchModule

View File

@@ -13,7 +13,7 @@ function HumanoidRPSettings:DisableRobloxSounds()
local Object = HRP_objects[i]
if Object:IsA("Sound") then
Object.SoundId = "rbxassetid://0"
Object.Volume = 0
end
end
end

View File

@@ -1,6 +1,14 @@
local Storage = game:GetService("ReplicatedStorage")
local ClientStorage = Storage:WaitForChild("Client")
local LoadCompleted = ClientStorage:WaitForChild("LoadingComplete")
--We need to wait for the game to load before spamming functionality
repeat
local GameIsLoaded = LoadCompleted:Invoke()
task.wait()
until GameIsLoaded
local HumanoidRPSettings = require(script:WaitForChild("HumanoidRootPart"))
local CameraModule = require(script:WaitForChild("Camera"))
local CrouchModule = require(script:WaitForChild("Crouch"))

View File

@@ -1,11 +1,29 @@
local CoreGuis = {
IncludeReset = true --disable the reset button?
AllowReset = false,
AllowEmotes = false, --controversial
AllowBackpack = false
}
CoreGuis.__index = CoreGuis
local SG = game:GetService("StarterGui")
local Players = game:GetService("Players")
local function DisableReset(enabled: boolean)
type CustomCoreGuiEnums = {Enum.CoreGuiType}
local function CustomCoreGuiEnums(): CustomCoreGuiEnums
local CoreElements = Enum.CoreGuiType:GetEnumItems()
table.remove(CoreElements, table.find(CoreElements, Enum.CoreGuiType.All))
if CoreGuis.AllowBackpack then
table.remove(CoreElements, table.find(CoreElements, Enum.CoreGuiType.Backpack))
end
if CoreGuis.AllowEmotes then
table.remove(CoreElements, table.find(CoreElements, Enum.CoreGuiType.EmotesMenu))
end
return CoreElements
end
local function ResetEnabled(enabled: boolean)
--Roblox actually doesn't register this fast enough so we gotta resort to cringe tactics
repeat
local PossibleMemoryLeak = pcall(SG.SetCore, SG, "ResetButtonCallback", enabled)
@@ -13,18 +31,46 @@ local function DisableReset(enabled: boolean)
until PossibleMemoryLeak
end
function CoreGuis:on()
SG:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
if CoreGuis.IncludeReset then
DisableReset(true)
function CoreGuis:On()
local Elements = CustomCoreGuiEnums()
for i = 1, #Elements do
SG:SetCoreGuiEnabled(Elements[i], true)
end
ResetEnabled(CoreGuis.AllowReset)
end
function CoreGuis:off()
SG:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
if CoreGuis.IncludeReset then
DisableReset(false)
function CoreGuis:Off()
if #Players:GetPlayers()>1 then
--Enable multiplayer features
self:On()
local PlayerAdded --So weird...
PlayerAdded = Players.PlayerAdded:Connect(function(_)
if #Players:GetPlayers()>1 then
self:On()
--We dont need to listen for players anymore
PlayerAdded:Disconnect()
end
end)
else
local Elements = CustomCoreGuiEnums()
for i = 1, #Elements do
SG:SetCoreGuiEnabled(Elements[i], false)
end
end
ResetEnabled(CoreGuis.AllowReset)
end
function CoreGuis:ForceOff()
SG:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
ResetEnabled(false)
end
function CoreGuis:ForceOn()
SG:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
ResetEnabled(true)
end
return CoreGuis

View File

@@ -9,11 +9,20 @@ 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 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()
@@ -28,17 +37,16 @@ local Crosshair = CrosshairSettings.constructor(PlayerGui)
local function CameraBinds()
local CameraBindMap = KeyBindsModule.constructor()
CameraBindMap:AddInputBegan(Enum.KeyCode.C, function()
CameraBindMap:AddInputBegan({Enum.KeyCode.C, Enum.KeyCode.Z}, function()
Camera:ZoomIn(Vignette, Crosshair)
end)
CameraBindMap:AddInputEnded(Enum.KeyCode.C, function()
CameraBindMap:AddInputEnded({Enum.KeyCode.C, Enum.KeyCode.Z}, function()
Camera:ZoomOut(Vignette, Crosshair)
end)
end
CoreGuis:off()
Mouse:DisablePointer()
Camera:FirstPerson()
Mouse:DisablePointer()
Crosshair:Enable()
CameraBinds()