mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
Loading gui work, needs finished
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
"ServerScriptService": {
|
||||
"$path": "src/server"
|
||||
},
|
||||
"ReplicatedFirst": {
|
||||
"$path": "src/load"
|
||||
},
|
||||
|
||||
"StarterPlayer": {
|
||||
"StarterPlayerScripts": {
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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
|
||||
@@ -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()
|
||||
144
src/load/intro/IntroGui.lua
Normal file
144
src/load/intro/IntroGui.lua
Normal file
@@ -0,0 +1,144 @@
|
||||
--Not a good idea to call modules from other services here
|
||||
|
||||
--Who said UI on here cant look like a web design lole,
|
||||
|
||||
local RS = game:GetService("RunService")
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local function GuiDependencies(IntroGui: ScreenGui): typeof(GuiDependencies)
|
||||
IntroGui.Enabled = true
|
||||
|
||||
local Frame = IntroGui:WaitForChild("Frame")
|
||||
local Viewport = Frame:WaitForChild("ViewportFrame")
|
||||
|
||||
local FrameGradient = Frame:WaitForChild("UIGradient")
|
||||
local TextShadow = Frame:WaitForChild("TextShadow")
|
||||
local FrameworkText = Frame:WaitForChild("Framework")
|
||||
local SandboxText = Frame:WaitForChild("Sandbox")
|
||||
local DeveloperText = Frame:WaitForChild("Developer")
|
||||
local ShadowGradient = TextShadow:WaitForChild("UIGradient")
|
||||
|
||||
local ViewportCamera = Instance.new("Camera")
|
||||
ViewportCamera.FieldOfView = 50
|
||||
ViewportCamera.Parent = Viewport
|
||||
Viewport.CurrentCamera = ViewportCamera
|
||||
|
||||
local GL_Cube = Viewport:WaitForChild("GL_Cube")
|
||||
|
||||
return {
|
||||
IntroGui = IntroGui,
|
||||
Frame = Frame,
|
||||
Viewport = Viewport,
|
||||
ViewportCamera = ViewportCamera,
|
||||
GL_Cube = GL_Cube,
|
||||
FrameGradient = FrameGradient,
|
||||
ShadowGradient = ShadowGradient,
|
||||
FrameworkText = FrameworkText,
|
||||
SandboxText = SandboxText,
|
||||
DeveloperText = DeveloperText
|
||||
}
|
||||
end
|
||||
|
||||
type GUIs = typeof(GuiDependencies)
|
||||
type GL_Cube = BasePart
|
||||
type GL_Side = BasePart
|
||||
|
||||
local function GL_Sides(GL_Cube: GL_Cube): {GL_Side}
|
||||
local Sides = {}
|
||||
local Cube_Sides = GL_Cube:GetChildren()
|
||||
for i = 1, #Cube_Sides do
|
||||
local Side = Cube_Sides[i]
|
||||
Sides[Side.Name] = {
|
||||
Part = Side,
|
||||
CF = Side.CFrame
|
||||
}
|
||||
end
|
||||
return Sides
|
||||
end
|
||||
|
||||
type Stepped = RBXScriptConnection
|
||||
|
||||
local function GUI_LoadFinish(Stepped: Stepped, Gui: GUIs)
|
||||
--We can now access the framework!
|
||||
--Image if we had HTML and CSS...
|
||||
local Tween = require(Storage:WaitForChild("Tween"))
|
||||
|
||||
local Bind_Completed = Instance.new("BindableFunction")
|
||||
Bind_Completed.Name = "LoadingComplete"
|
||||
Bind_Completed.Parent = Storage:WaitForChild("Client")
|
||||
Bind_Completed.OnInvoke = function()
|
||||
return game:IsLoaded() --or just returning a static true
|
||||
end
|
||||
|
||||
local EaseStyle = Enum.EasingStyle.Linear
|
||||
|
||||
local FrameTween_Constructor = Tween.constructor(TweenInfo.new(1, EaseStyle), Gui.Frame, {
|
||||
BackgroundTransparency = 1
|
||||
})
|
||||
local DeveloperTween_Constructor = Tween.constructor(TweenInfo.new(1, EaseStyle), Gui.DeveloperText, {
|
||||
TextTransparency = 1
|
||||
})
|
||||
local ViewportFrame_Constructor = Tween.constructor(TweenInfo.new(3, EaseStyle), Gui.Viewport, {
|
||||
Position = UDim2.fromScale(0.5, 2) --Guaranteed off screen
|
||||
})
|
||||
|
||||
FrameTween_Constructor:Start()
|
||||
DeveloperTween_Constructor:Start()
|
||||
local ViewportTween = ViewportFrame_Constructor:Start() --The longest tween
|
||||
|
||||
task.spawn(function()
|
||||
local Promise_60 = 1/60
|
||||
local rhpid_text_len = #Gui.FrameworkText
|
||||
local sandbox_text_len = #Gui.SandboxText.Text
|
||||
|
||||
for i = 1, sandbox_text_len do --"A sandbox experience" has the longest text
|
||||
Gui.SandboxText.Text = Gui.SandboxText.Text:sub(rhpid_text_len)
|
||||
task.wait(Promise_60)
|
||||
end
|
||||
end)
|
||||
ViewportTween.Completed:Wait()
|
||||
Stepped:Disconnect()
|
||||
Gui.IntroGui:Destroy() --We dont need the intro gui anymore
|
||||
end
|
||||
|
||||
return function(IntroGui: ScreenGui, load_elapse_start: number)
|
||||
local Gui = GuiDependencies(IntroGui)
|
||||
|
||||
local CubeSides = GL_Sides(Gui.GL_Cube)
|
||||
local Red = CubeSides.Red
|
||||
local Green = CubeSides.Green
|
||||
local Blue = CubeSides.Blue
|
||||
local Purple = CubeSides.Purple
|
||||
local Yellow = CubeSides.Yellow
|
||||
local Pink = CubeSides.Pink
|
||||
Gui.ViewportCamera.CFrame = CFrame.lookAt(Gui.GL_Cube.Position-Vector3.new(3,-2.5,3), Gui.GL_Cube.Position)
|
||||
|
||||
local Cube_CF = Gui.GL_Cube.CFrame
|
||||
local Stepped = RS.Stepped:Connect(function(delta, dt)
|
||||
--Magic number heaven
|
||||
local ROT = CFrame.Angles(math.rad(100*math.cos(delta/8)), 0, delta/2)
|
||||
local d2 = delta*10
|
||||
|
||||
Gui.FrameGradient.Rotation=d2
|
||||
Gui.ShadowGradient.Rotation=d2*4
|
||||
|
||||
Gui.GL_Cube.CFrame = Cube_CF*ROT
|
||||
Yellow.Part.CFrame = Gui.GL_Cube.CFrame*CFrame.new(-1,0,0)*CFrame.fromEulerAnglesYXZ(0,math.rad(90),0)
|
||||
Green.Part.CFrame = Gui.GL_Cube.CFrame*CFrame.new(1,0,0)*CFrame.fromEulerAnglesYXZ(0,math.rad(90),0)
|
||||
Pink.Part.CFrame = Gui.GL_Cube.CFrame*CFrame.new(0,-1,0)*CFrame.fromEulerAnglesYXZ(math.rad(-90),0,0)
|
||||
Blue.Part.CFrame = Gui.GL_Cube.CFrame*CFrame.new(0,1,0)*CFrame.fromEulerAnglesYXZ(math.rad(-90),0,0)
|
||||
Red.Part.CFrame = Gui.GL_Cube.CFrame*CFrame.new(0,0,1)
|
||||
Purple.Part.CFrame = Gui.GL_Cube.CFrame*CFrame.new(0,0,-1)
|
||||
end)
|
||||
|
||||
task.spawn(function()
|
||||
if not game:IsLoaded() then
|
||||
game.Loaded:Wait()
|
||||
end
|
||||
local load_elapse = os.clock()-load_elapse_start
|
||||
--artifical wait but only if you dont take longer than 3 seconds to load the actual game (let me have my fun),
|
||||
task.wait(math.max(0, 3-load_elapse))
|
||||
|
||||
GUI_LoadFinish(Stepped, Gui)
|
||||
end)
|
||||
end
|
||||
34
src/load/intro/init.client.lua
Normal file
34
src/load/intro/init.client.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
local load_elapse_start = os.clock()
|
||||
|
||||
local ReplicatedFirst = game:GetService("ReplicatedFirst")
|
||||
local Players = game:GetService("Players")
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local RunIntroGui = require(script:WaitForChild("IntroGui"))
|
||||
|
||||
local Player = Players.LocalPlayer
|
||||
if not Player then
|
||||
repeat
|
||||
Player = Players.LocalPlayer
|
||||
task.wait()
|
||||
until Player
|
||||
end
|
||||
|
||||
local PlayerGui = Player:WaitForChild("PlayerGui")
|
||||
local IntroGui = PlayerGui:WaitForChild("rhpidframework_intro", 10)
|
||||
|
||||
if IntroGui then
|
||||
--Let the magic begin
|
||||
RunIntroGui(IntroGui, load_elapse_start)
|
||||
else
|
||||
warn("Waited 10 seconds for the intro gui without success")
|
||||
|
||||
local Bind_Completed = Instance.new("BindableFunction")
|
||||
Bind_Completed.Name = "LoadingComplete"
|
||||
Bind_Completed.Parent = Storage:WaitForChild("Client")
|
||||
Bind_Completed.OnInvoke = function()
|
||||
return game:IsLoaded() --or just returning a static true
|
||||
end
|
||||
end
|
||||
|
||||
ReplicatedFirst:RemoveDefaultLoadingScreen()
|
||||
@@ -3,6 +3,10 @@ local Lighting = require(script:WaitForChild("Lighting"))
|
||||
|
||||
local RS = game:GetService("RunService")
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
local StarterPlayer = game:GetService("StarterPlayer")
|
||||
|
||||
StarterPlayer.CharacterWalkSpeed = 0
|
||||
StarterPlayer.CharacterJumpHeight = 0
|
||||
|
||||
local ServerStorage = Storage:WaitForChild("Server")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user