mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
UDP flashlight working and fix some type errors
This commit is contained in:
@@ -5,6 +5,10 @@
|
|||||||
local Actions = {}
|
local Actions = {}
|
||||||
Actions.__index = Actions
|
Actions.__index = Actions
|
||||||
|
|
||||||
|
type UDP = UnreliableRemoteEvent
|
||||||
|
type TCP = RemoteEvent
|
||||||
|
type inherented = any
|
||||||
|
|
||||||
--Sneak static properties
|
--Sneak static properties
|
||||||
Actions.DoingAction = false
|
Actions.DoingAction = false
|
||||||
Actions.Sneaking = false
|
Actions.Sneaking = false
|
||||||
@@ -21,7 +25,7 @@ Actions.CrouchSpeed = .2
|
|||||||
Actions.FlashlightEnabled = false
|
Actions.FlashlightEnabled = false
|
||||||
|
|
||||||
local CharacterShared = _G.include(script, "CharacterShared")
|
local CharacterShared = _G.include(script, "CharacterShared")
|
||||||
local FlashlightRemote: UnreliableRemoteEvent = CharacterShared:WaitForChild("Flashlight")
|
local FlashlightRemote: UDP = CharacterShared:WaitForChild("Flashlight")
|
||||||
|
|
||||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||||
|
|
||||||
@@ -30,13 +34,12 @@ local Delta = require(Storage:WaitForChild("Delta"))
|
|||||||
|
|
||||||
local CrouchTween = Tween.constructor()
|
local CrouchTween = Tween.constructor()
|
||||||
|
|
||||||
type inherented = any
|
function Actions.constructor(HumanoidSettings: inherented, CurrentCamera: Camera, ActionsTCP: TCP)
|
||||||
|
|
||||||
function Actions.constructor(HumanoidSettings: inherented, Humanoid: Humanoid, CurrentCamera: Camera)
|
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
Humanoid = Humanoid,
|
Humanoid = HumanoidSettings.Humanoid,
|
||||||
HumanoidSettings = HumanoidSettings,
|
HumanoidSettings = HumanoidSettings,
|
||||||
CurrentCamera = CurrentCamera
|
CurrentCamera = CurrentCamera,
|
||||||
|
ActionsTCP = ActionsTCP
|
||||||
}, Actions)
|
}, Actions)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -52,69 +55,55 @@ function Actions:DisableSneak()
|
|||||||
self.HumanoidSettings:SetWalkSpeed(Actions.Walk)
|
self.HumanoidSettings:SetWalkSpeed(Actions.Walk)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Actions:EnableCrouch(StandingWalkSpeed: number)
|
function Actions:EnableCrouch()
|
||||||
Actions.DoingAction = true
|
Actions.DoingAction = true
|
||||||
Actions.Crouching = true
|
Actions.Crouching = true
|
||||||
|
|
||||||
local Easing = TweenInfo.new(Actions.CrouchSpeed, Enum.EasingStyle.Linear)
|
local Easing = TweenInfo.new(Actions.CrouchSpeed, Enum.EasingStyle.Linear)
|
||||||
|
local WalkSpeed = (self.Humanoid :: Humanoid).WalkSpeed
|
||||||
|
|
||||||
CrouchTween:Start(self.Humanoid, {
|
CrouchTween:Start(self.Humanoid, {
|
||||||
HipHeight = Actions.CrouchHeight,
|
HipHeight = Actions.CrouchHeight,
|
||||||
WalkSpeed = math.max(1, StandingWalkSpeed-Actions.WalkSpeedMultiplier)
|
WalkSpeed = math.max(1, WalkSpeed-Actions.WalkSpeedMultiplier)
|
||||||
}, Easing)
|
}, Easing)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Actions:DisableCrouch(CrouchingWalkSpeed: number)
|
function Actions:DisableCrouch()
|
||||||
Actions.DoingAction = false
|
Actions.DoingAction = false
|
||||||
Actions.Crouching = false
|
Actions.Crouching = false
|
||||||
|
|
||||||
local Easing = TweenInfo.new(Actions.CrouchSpeed, Enum.EasingStyle.Linear)
|
local Easing = TweenInfo.new(Actions.CrouchSpeed, Enum.EasingStyle.Linear)
|
||||||
|
local WalkSpeed = (self.Humanoid :: Humanoid).WalkSpeed
|
||||||
|
|
||||||
CrouchTween:Start(self.Humanoid, {
|
CrouchTween:Start(self.Humanoid, {
|
||||||
HipHeight = Actions.StandHeight,
|
HipHeight = Actions.StandHeight,
|
||||||
WalkSpeed = math.max(1, CrouchingWalkSpeed+Actions.WalkSpeedMultiplier)
|
WalkSpeed = math.max(1, WalkSpeed+Actions.WalkSpeedMultiplier)
|
||||||
}, Easing)
|
}, Easing)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Actions:EnableFlashlight()
|
function Actions:EnableFlashlight(FlashlightKey: Enum.KeyCode)
|
||||||
Actions.FlashlightEnabled = true
|
Actions.FlashlightEnabled = true
|
||||||
|
|
||||||
task.spawn(function()
|
task.spawn(function()
|
||||||
while Actions.FlashlightEnabled do
|
while Actions.FlashlightEnabled do
|
||||||
FlashlightRemote:FireServer()
|
FlashlightRemote:FireServer(self.CurrentCamera.CFrame)
|
||||||
Delta:time()
|
Delta:time()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
self.ActionsTCP:FireServer(FlashlightKey)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Actions:DisableFlashlight()
|
function Actions:DisableFlashlight(FlashlightKey: Enum.KeyCode)
|
||||||
|
self.ActionsTCP:FireServer(FlashlightKey)
|
||||||
Actions.FlashlightEnabled = false
|
Actions.FlashlightEnabled = false
|
||||||
end
|
end
|
||||||
|
|
||||||
function Actions:EnableFlashlight()
|
function Actions:ToggleFlashlight(FlashlightKey: Enum.KeyCode)
|
||||||
if Actions.FlashlightEnabled then
|
if Actions.FlashlightEnabled then
|
||||||
|
self:DisableFlashlight(FlashlightKey)
|
||||||
else
|
else
|
||||||
|
self:EnableFlashlight(FlashlightKey)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Actions:ToggleCrouch()
|
return Actions
|
||||||
if not Actions.DoingAction then
|
|
||||||
if Actions.Crouching then
|
|
||||||
self:DisableCrouch()
|
|
||||||
else
|
|
||||||
self:EnableCrouch()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Actions:ToggleSneak()
|
|
||||||
if not Actions.DoingAction then
|
|
||||||
if Actions.Sneaking then
|
|
||||||
self:DisableSneak()
|
|
||||||
else
|
|
||||||
self:EnableSneak()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -11,9 +11,18 @@ local RS = game:GetService("RunService")
|
|||||||
local Bobbing = require(script:WaitForChild("Bobbing"))
|
local Bobbing = require(script:WaitForChild("Bobbing"))
|
||||||
|
|
||||||
type FakeCamera = BasePart
|
type FakeCamera = BasePart
|
||||||
|
type CurrentCamera = Camera
|
||||||
|
type HumanoidRootPart = BasePart
|
||||||
|
|
||||||
function Camera.constructor(CurrentCamera: Camera, HumanoidRootPart: BasePart, Humanoid: Humanoid)
|
type Camera_struct = {
|
||||||
local self = {}
|
CameraFPS: boolean,
|
||||||
|
CurrentCamera: CurrentCamera,
|
||||||
|
HumanoidRootPart: HumanoidRootPart,
|
||||||
|
BobbingCamera: any
|
||||||
|
}
|
||||||
|
|
||||||
|
function Camera.constructor(CurrentCamera: CurrentCamera, HumanoidRootPart: HumanoidRootPart, Humanoid: Humanoid)
|
||||||
|
local self = {} :: Camera_struct
|
||||||
self.CameraFPS = false
|
self.CameraFPS = false
|
||||||
self.CurrentCamera = CurrentCamera
|
self.CurrentCamera = CurrentCamera
|
||||||
self.HumanoidRootPart = HumanoidRootPart
|
self.HumanoidRootPart = HumanoidRootPart
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function HumanoidRPSettings:DisableRobloxSounds()
|
|||||||
local Object = HRP_objects[i]
|
local Object = HRP_objects[i]
|
||||||
|
|
||||||
if Object:IsA("Sound") then
|
if Object:IsA("Sound") then
|
||||||
Object.Volume = 0
|
(Object :: Sound).Volume = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,6 +7,15 @@ local Spine = {
|
|||||||
}
|
}
|
||||||
Spine.__index = Spine
|
Spine.__index = Spine
|
||||||
|
|
||||||
|
type UDP = UnreliableRemoteEvent
|
||||||
|
type CurrentCamera = Camera
|
||||||
|
|
||||||
|
type struct_Spine = {
|
||||||
|
Remote: UDP,
|
||||||
|
CurrentCamera: CurrentCamera
|
||||||
|
}
|
||||||
|
type CharacterSharedFolder = Folder
|
||||||
|
|
||||||
local Storage = game:GetService("ReplicatedStorage")
|
local Storage = game:GetService("ReplicatedStorage")
|
||||||
local Players = game:GetService("Players")
|
local Players = game:GetService("Players")
|
||||||
|
|
||||||
@@ -15,14 +24,6 @@ local Delta = require(Storage:WaitForChild("Delta"))
|
|||||||
local Player = Players.LocalPlayer
|
local Player = Players.LocalPlayer
|
||||||
local CharacterShared = _G.include(script, "CharacterShared")
|
local CharacterShared = _G.include(script, "CharacterShared")
|
||||||
|
|
||||||
type CurrentCamera = Camera
|
|
||||||
|
|
||||||
type struct_Spine = {
|
|
||||||
Remote: UnreliableRemoteEvent,
|
|
||||||
CurrentCamera: CurrentCamera
|
|
||||||
}
|
|
||||||
type CharacterSharedFolder = Folder
|
|
||||||
|
|
||||||
function Spine.constructor(CurrentCamera: CurrentCamera)
|
function Spine.constructor(CurrentCamera: CurrentCamera)
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
Remote = CharacterShared:WaitForChild("SpineStream"),
|
Remote = CharacterShared:WaitForChild("SpineStream"),
|
||||||
|
|||||||
@@ -2,14 +2,17 @@
|
|||||||
--!native
|
--!native
|
||||||
--!strict
|
--!strict
|
||||||
|
|
||||||
|
type CharacterSharedFolder = Folder
|
||||||
|
type TCP = RemoteEvent
|
||||||
|
|
||||||
local Dir = script.Parent
|
local Dir = script.Parent
|
||||||
local Character = Dir.Parent
|
local Character = Dir.Parent
|
||||||
|
local CharacterShared = Dir:WaitForChild("shared")
|
||||||
|
|
||||||
local preprocessor = {}
|
local preprocessor = {}
|
||||||
|
|
||||||
type CharacterSharedFolder = Folder
|
|
||||||
|
|
||||||
function preprocessor.CharacterShared(): CharacterSharedFolder
|
function preprocessor.CharacterShared(): CharacterSharedFolder
|
||||||
return Dir:WaitForChild("shared")
|
return CharacterShared
|
||||||
end
|
end
|
||||||
|
|
||||||
_G.include = function(this: LuaSourceContainer, FunName: string, ...)
|
_G.include = function(this: LuaSourceContainer, FunName: string, ...)
|
||||||
@@ -23,23 +26,23 @@ _G.include = function(this: LuaSourceContainer, FunName: string, ...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||||
local RS: RunService = game:GetService("RunService")
|
local RS: RunService = game:GetService("RunService")
|
||||||
|
|
||||||
local ClientStorage = Storage:WaitForChild("Client")
|
local ClientStorage: Instance = Storage:WaitForChild("Client") :: Folder
|
||||||
local LoadCompleted = ClientStorage:WaitForChild("LoadingComplete")
|
local LoadCompleted: Instance = ClientStorage:WaitForChild("LoadingComplete") :: BindableFunction
|
||||||
|
local ActionsTCP: TCP = CharacterShared:WaitForChild("Actions")
|
||||||
|
|
||||||
--We need to wait for the game to load before spamming functionality
|
--We need to wait for the game to load before spamming functionality
|
||||||
repeat
|
repeat
|
||||||
local GameIsLoaded = LoadCompleted:Invoke()
|
local GameIsLoaded = (LoadCompleted :: BindableFunction):Invoke()
|
||||||
task.wait()
|
task.wait()
|
||||||
until GameIsLoaded
|
until GameIsLoaded
|
||||||
|
|
||||||
local HumanoidRPSettings = require(script:WaitForChild("HumanoidRootPart"))
|
local HumanoidRPSettings = require(script:WaitForChild("HumanoidRootPart"))
|
||||||
local CameraModule = require(script:WaitForChild("Camera"))
|
local CameraModule = require(script:WaitForChild("Camera"))
|
||||||
local CrouchModule = require(script:WaitForChild("Crouch"))
|
|
||||||
local HumanoidModule = require(script:WaitForChild("Humanoid"))
|
local HumanoidModule = require(script:WaitForChild("Humanoid"))
|
||||||
local SpineModule = require(script:WaitForChild("SpineKinematics"))
|
local SpineModule = require(script:WaitForChild("SpineKinematics"))
|
||||||
local FlashlightModule = require(script:WaitForChild("Flashlight"))
|
local ActionsModule = require(script:WaitForChild("Actions"))
|
||||||
local BindModule = require(ClientStorage:WaitForChild("KeyBinds"))
|
local BindModule = require(ClientStorage:WaitForChild("KeyBinds"))
|
||||||
|
|
||||||
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
|
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
|
||||||
@@ -54,47 +57,48 @@ local SpineMovement = SpineModule.constructor(CurrentCamera)
|
|||||||
local ClientBindMap = BindModule.constructor(false)
|
local ClientBindMap = BindModule.constructor(false)
|
||||||
|
|
||||||
local function ClientCharacterBinds()
|
local function ClientCharacterBinds()
|
||||||
local CrouchConstructor = CrouchModule.constructor(Humanoid)
|
local Actions = ActionsModule.constructor(HumanoidSettings, CurrentCamera, ActionsTCP)
|
||||||
|
|
||||||
--Crouch
|
--Crouch
|
||||||
ClientBindMap:AddInputBegan({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function()
|
ClientBindMap:AddInputBegan({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function(_KeyPressed)
|
||||||
CrouchConstructor:Crouch(10)
|
Actions:EnableCrouch()
|
||||||
end)
|
end)
|
||||||
ClientBindMap:AddInputEnded({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function()
|
ClientBindMap:AddInputEnded({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function(_KeyPressed)
|
||||||
CrouchConstructor:Stand(5)
|
Actions:DisableCrouch()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--Walk
|
--Walk
|
||||||
ClientBindMap:AddInputBegan({Enum.KeyCode.LeftAlt, Enum.KeyCode.RightAlt}, function()
|
ClientBindMap:AddInputBegan({
|
||||||
HumanoidSettings:SetWalkSpeed(Walking)
|
Enum.KeyCode.LeftAlt,
|
||||||
|
Enum.KeyCode.RightAlt,
|
||||||
|
Enum.KeyCode.LeftShift,
|
||||||
|
Enum.KeyCode.RightShift
|
||||||
|
}, function(_KeyPressed)
|
||||||
|
Actions:EnableSneak()
|
||||||
end)
|
end)
|
||||||
ClientBindMap:AddInputEnded({Enum.KeyCode.LeftAlt, Enum.KeyCode.RightAlt}, function()
|
ClientBindMap:AddInputEnded({
|
||||||
HumanoidSettings:SetWalkSpeed(10)
|
Enum.KeyCode.LeftAlt,
|
||||||
|
Enum.KeyCode.RightAlt,
|
||||||
|
Enum.KeyCode.LeftShift,
|
||||||
|
Enum.KeyCode.RightShift
|
||||||
|
}, function(_KeyPressed)
|
||||||
|
Actions:DisableSneak()
|
||||||
end)
|
end)
|
||||||
--Sprint
|
|
||||||
ClientBindMap:AddInputBegan({Enum.KeyCode.LeftShift, Enum.KeyCode.RightShift}, function()
|
--Flashlight
|
||||||
|
ClientBindMap:AddInputBegan({Enum.KeyCode.F}, function(KeyPressed: Enum.KeyCode)
|
||||||
end)
|
Actions:ToggleFlashlight(KeyPressed)
|
||||||
ClientBindMap:AddInputEnded({Enum.KeyCode.LeftShift, Enum.KeyCode.RightShift}, function()
|
|
||||||
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Crosshair3DVelocity_Effect(): RBXScriptSignal
|
--Needs to be a module maybe
|
||||||
|
local function Crosshair3DVelocity_Effect(): RBXScriptConnection
|
||||||
local RootVelocity = ClientStorage:WaitForChild("RootVelocity") :: BindableEvent
|
local RootVelocity = ClientStorage:WaitForChild("RootVelocity") :: BindableEvent
|
||||||
|
|
||||||
local RootVelocitySteps = RS.Heartbeat:ConnectParallel(function(_dt)
|
local RootVelocityStep = RS.Heartbeat:ConnectParallel(function(_dt)
|
||||||
RootVelocity:Fire(HRPSettings:Velocity())
|
RootVelocity:Fire(HRPSettings:Velocity())
|
||||||
end)
|
end)
|
||||||
return RootVelocitySteps
|
return RootVelocityStep
|
||||||
end
|
|
||||||
|
|
||||||
local function FlashlightToggle()
|
|
||||||
ClientBindMap:AddInputBegan({Enum.KeyCode.F}, function()
|
|
||||||
Flashlight:Toggle()
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function HealthChangeBind()
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
HumanoidSettings:SetWalkSpeed()
|
HumanoidSettings:SetWalkSpeed()
|
||||||
@@ -105,6 +109,5 @@ SpineMovement:Enable()
|
|||||||
|
|
||||||
ClientCharacterBinds()
|
ClientCharacterBinds()
|
||||||
Crosshair3DVelocity_Effect()
|
Crosshair3DVelocity_Effect()
|
||||||
FlashlightToggle()
|
|
||||||
|
|
||||||
_G.include = nil
|
_G.include = nil
|
||||||
@@ -5,18 +5,20 @@
|
|||||||
local Actions = {}
|
local Actions = {}
|
||||||
Actions.__index = Actions
|
Actions.__index = Actions
|
||||||
|
|
||||||
type EventFunction = (...any) -> ()
|
type EventFunction = (KeyPressed: Enum.KeyCode) -> ()
|
||||||
type ActionsTCP = RBXScriptConnection
|
type ActionsTCP = RBXScriptConnection
|
||||||
|
type LocalPlayer = Player
|
||||||
|
type TCP = RemoteEvent
|
||||||
|
|
||||||
local CharacterShared = _G.include(script, "CharacterShared")
|
local CharacterShared = _G.include(script, "CharacterShared")
|
||||||
|
|
||||||
local Remote = Instance.new("RemoteEvent") :: RemoteEvent
|
local Remote = Instance.new("RemoteEvent") :: TCP
|
||||||
Remote.Name = "ActionsBind"
|
Remote.Name = "Actions"
|
||||||
Remote.Parent = CharacterShared
|
Remote.Parent = CharacterShared
|
||||||
|
|
||||||
local ActionsTCP_Event: ActionsTCP?
|
local ActionsTCP_Event: ActionsTCP?
|
||||||
|
|
||||||
function Actions.constructor(LocalPlayer: Player)
|
function Actions.constructor(LocalPlayer: LocalPlayer)
|
||||||
local Events: {
|
local Events: {
|
||||||
[Enum.KeyCode]: EventFunction
|
[Enum.KeyCode]: EventFunction
|
||||||
} = {}
|
} = {}
|
||||||
@@ -29,7 +31,7 @@ function Actions.constructor(LocalPlayer: Player)
|
|||||||
if typeof(Key) == "EnumItem" then
|
if typeof(Key) == "EnumItem" then
|
||||||
local switch = Events[Key]
|
local switch = Events[Key]
|
||||||
if switch then
|
if switch then
|
||||||
switch()
|
switch(Key)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
warn(`[Server Actions]: Got an unknown type, Key="{typeof(Key)}" Value="{Key}" from: "{Messenger.Name}"`)
|
warn(`[Server Actions]: Got an unknown type, Key="{typeof(Key)}" Value="{Key}" from: "{Messenger.Name}"`)
|
||||||
|
|||||||
@@ -5,9 +5,22 @@
|
|||||||
local Flashlight = {}
|
local Flashlight = {}
|
||||||
Flashlight.__index = Flashlight
|
Flashlight.__index = Flashlight
|
||||||
|
|
||||||
|
type UDP = UnreliableRemoteEvent
|
||||||
|
type FlashlightUDP = RBXScriptConnection
|
||||||
|
type LocalPlayer = Player
|
||||||
|
type HumanoidRootPart = BasePart
|
||||||
|
|
||||||
Flashlight.Enabled = false
|
Flashlight.Enabled = false
|
||||||
|
|
||||||
function Flashlight.constructor(HumanoidRootPart: BasePart)
|
local CharacterShared = _G.include(script, "CharacterShared")
|
||||||
|
|
||||||
|
local Flashlight_UDP = Instance.new("UnreliableRemoteEvent") :: UDP
|
||||||
|
Flashlight_UDP.Name = "Flashlight"
|
||||||
|
Flashlight_UDP.Parent = CharacterShared
|
||||||
|
|
||||||
|
local FlashlightUDP_Event: FlashlightUDP?
|
||||||
|
|
||||||
|
function Flashlight.constructor(LocalPlayer: LocalPlayer, HumanoidRootPart: HumanoidRootPart)
|
||||||
local FlashlightPart = Instance.new("Part") :: Part
|
local FlashlightPart = Instance.new("Part") :: Part
|
||||||
FlashlightPart.Size = Vector3.new(.1,.1,.1)
|
FlashlightPart.Size = Vector3.new(.1,.1,.1)
|
||||||
FlashlightPart.CFrame = HumanoidRootPart.CFrame
|
FlashlightPart.CFrame = HumanoidRootPart.CFrame
|
||||||
@@ -18,21 +31,30 @@ function Flashlight.constructor(HumanoidRootPart: BasePart)
|
|||||||
|
|
||||||
local SpotLight = Instance.new("SpotLight") :: SpotLight
|
local SpotLight = Instance.new("SpotLight") :: SpotLight
|
||||||
SpotLight.Color = Color3.new(1,1,1)
|
SpotLight.Color = Color3.new(1,1,1)
|
||||||
SpotLight.Angle = 90
|
SpotLight.Angle = 80
|
||||||
SpotLight.Range = 30
|
SpotLight.Range = 30
|
||||||
SpotLight.Brightness = 1
|
SpotLight.Brightness = 2
|
||||||
SpotLight.Shadows = true
|
SpotLight.Shadows = true
|
||||||
SpotLight.Enabled = false
|
SpotLight.Enabled = false
|
||||||
SpotLight.Parent = FlashlightPart
|
SpotLight.Parent = FlashlightPart
|
||||||
|
|
||||||
FlashlightPart.Anchored = false
|
|
||||||
FlashlightPart.Parent = HumanoidRootPart
|
FlashlightPart.Parent = HumanoidRootPart
|
||||||
|
|
||||||
local ToggleSound = Instance.new("Sound") :: Sound
|
local ToggleSound = Instance.new("Sound") :: Sound
|
||||||
|
ToggleSound.Name = "Flashlight"
|
||||||
ToggleSound.SoundId = "rbxassetid://16454678462"
|
ToggleSound.SoundId = "rbxassetid://16454678462"
|
||||||
ToggleSound.Volume = .5
|
ToggleSound.Volume = .5
|
||||||
ToggleSound.Parent = HumanoidRootPart
|
ToggleSound.Parent = HumanoidRootPart
|
||||||
|
|
||||||
|
if FlashlightUDP_Event then
|
||||||
|
warn("[Server Flashlight]: UDP event was already created, duplicating...", debug.traceback())
|
||||||
|
end
|
||||||
|
FlashlightUDP_Event = Flashlight_UDP.OnServerEvent:Connect(function(Messenger: Player, CameraCFrame: CFrame)
|
||||||
|
if Messenger.UserId == LocalPlayer.UserId then
|
||||||
|
FlashlightPart.CFrame = CameraCFrame
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
FlashlightPart = FlashlightPart,
|
FlashlightPart = FlashlightPart,
|
||||||
SpotLight = SpotLight,
|
SpotLight = SpotLight,
|
||||||
@@ -40,10 +62,9 @@ function Flashlight.constructor(HumanoidRootPart: BasePart)
|
|||||||
}, Flashlight)
|
}, Flashlight)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Flashlight:On(CameraCFrame: CFrame)
|
function Flashlight:On()
|
||||||
Flashlight.Enabled = true
|
Flashlight.Enabled = true
|
||||||
|
|
||||||
(self.FlashlightPart :: Part).CFrame *= CameraCFrame;
|
|
||||||
(self.ToggleSound :: Sound):Play();
|
(self.ToggleSound :: Sound):Play();
|
||||||
(self.SpotLight :: SpotLight).Enabled = Flashlight.Enabled
|
(self.SpotLight :: SpotLight).Enabled = Flashlight.Enabled
|
||||||
end
|
end
|
||||||
@@ -55,11 +76,11 @@ function Flashlight:Off()
|
|||||||
(self.SpotLight :: SpotLight).Enabled = Flashlight.Enabled
|
(self.SpotLight :: SpotLight).Enabled = Flashlight.Enabled
|
||||||
end
|
end
|
||||||
|
|
||||||
function Flashlight:Toggle(CameraCFrame: CFrame?)
|
function Flashlight:Toggle()
|
||||||
if Flashlight.Enabled then
|
if Flashlight.Enabled then
|
||||||
self:Off()
|
self:Off()
|
||||||
else
|
else
|
||||||
self:On(CameraCFrame :: CFrame)
|
self:On()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,10 @@ type Waist = Motor6D
|
|||||||
type NeckC0 = CFrame
|
type NeckC0 = CFrame
|
||||||
type WaistC0 = CFrame
|
type WaistC0 = CFrame
|
||||||
|
|
||||||
|
type UDP = UnreliableRemoteEvent
|
||||||
|
|
||||||
type struct_Spine = {
|
type struct_Spine = {
|
||||||
Remote: UnreliableRemoteEvent,
|
Remote: UDP,
|
||||||
Head: Head,
|
Head: Head,
|
||||||
UpperTorso: UpperTorso,
|
UpperTorso: UpperTorso,
|
||||||
Neck: Neck,
|
Neck: Neck,
|
||||||
@@ -36,7 +38,7 @@ function Spine.constructor(Head: Head, UpperTorso: UpperTorso)
|
|||||||
self.UpperTorso = UpperTorso
|
self.UpperTorso = UpperTorso
|
||||||
self.Neck = Head:WaitForChild("Neck") :: Neck
|
self.Neck = Head:WaitForChild("Neck") :: Neck
|
||||||
self.Waist = UpperTorso:WaitForChild("Waist") :: Waist
|
self.Waist = UpperTorso:WaitForChild("Waist") :: Waist
|
||||||
self.Remote = Remote :: UnreliableRemoteEvent
|
self.Remote = Remote :: UDP
|
||||||
|
|
||||||
self.NeckC0 = self.Neck.C0
|
self.NeckC0 = self.Neck.C0
|
||||||
self.WaistC0 = self.Waist.C0
|
self.WaistC0 = self.Waist.C0
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
--!native
|
--!native
|
||||||
--!strict
|
--!strict
|
||||||
|
|
||||||
|
type UDP = UnreliableRemoteEvent
|
||||||
|
|
||||||
local Dir = script.Parent
|
local Dir = script.Parent
|
||||||
local Character = Dir.Parent
|
local Character = Dir.Parent
|
||||||
local preprocessor = {}
|
local preprocessor = {}
|
||||||
@@ -36,15 +38,16 @@ local SpineModule = require(script:WaitForChild("SpineKinematics"))
|
|||||||
local FlashlightModule = require(script:WaitForChild("Flashlight"))
|
local FlashlightModule = require(script:WaitForChild("Flashlight"))
|
||||||
local ActionsModule = require(script:WaitForChild("Actions"))
|
local ActionsModule = require(script:WaitForChild("Actions"))
|
||||||
|
|
||||||
local Head = Character:WaitForChild("Head")
|
local Head = Character:WaitForChild("Head")
|
||||||
local UpperTorso = Character:WaitForChild("UpperTorso")
|
local UpperTorso = Character:WaitForChild("UpperTorso")
|
||||||
|
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
|
||||||
|
|
||||||
local LocalPlayer = Players:GetPlayerFromCharacter(Character)
|
local LocalPlayer = Players:GetPlayerFromCharacter(Character)
|
||||||
|
|
||||||
local CharacterShadows = Shadows.constructor(Character)
|
local CharacterShadows = Shadows.constructor(Character)
|
||||||
local Spine = SpineModule.constructor(Head, UpperTorso)
|
local Spine = SpineModule.constructor(Head, UpperTorso)
|
||||||
local Flashlight = FlashlightModule.constructor(Head)
|
local Flashlight = FlashlightModule.constructor(LocalPlayer, HumanoidRootPart)
|
||||||
local Actions = ActionsModule.constructor(LocalPlayer)
|
local Actions = ActionsModule.constructor(LocalPlayer, HumanoidRootPart)
|
||||||
|
|
||||||
local FlashlightDebounce = false
|
local FlashlightDebounce = false
|
||||||
|
|
||||||
@@ -55,7 +58,7 @@ Character.DescendantAdded:Connect(function(Instance)
|
|||||||
CharacterShadows:PartToggle(Instance, false)
|
CharacterShadows:PartToggle(Instance, false)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Actions:Add(Enum.KeyCode.F, function()
|
Actions:Add(Enum.KeyCode.F, function(_KeyPressed)
|
||||||
if not FlashlightDebounce then
|
if not FlashlightDebounce then
|
||||||
Flashlight:Toggle()
|
Flashlight:Toggle()
|
||||||
|
|
||||||
@@ -63,9 +66,9 @@ Actions:Add(Enum.KeyCode.F, function()
|
|||||||
task.wait(FlashlightCooldown)
|
task.wait(FlashlightCooldown)
|
||||||
FlashlightDebounce = false
|
FlashlightDebounce = false
|
||||||
end
|
end
|
||||||
end)
|
end);
|
||||||
|
|
||||||
Spine.Remote.OnServerEvent:Connect(function(Messenger: Player, CameraPosition: CFrame, IsFirstPerson: boolean)
|
(Spine.Remote :: UDP).OnServerEvent:Connect(function(Messenger: Player, CameraPosition: CFrame, IsFirstPerson: boolean)
|
||||||
if Messenger.UserId == LocalPlayer.UserId then
|
if Messenger.UserId == LocalPlayer.UserId then
|
||||||
if Spine.Enabled then
|
if Spine.Enabled then
|
||||||
Spine:Move(CameraPosition, IsFirstPerson)
|
Spine:Move(CameraPosition, IsFirstPerson)
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ local HealthSettings = require(UI:WaitForChild("Health"))
|
|||||||
local CoreGuis = require(script:WaitForChild("CoreGuis"))
|
local CoreGuis = require(script:WaitForChild("CoreGuis"))
|
||||||
local Mouse = require(script:WaitForChild("Mouse"))
|
local Mouse = require(script:WaitForChild("Mouse"))
|
||||||
|
|
||||||
local Players = game:GetService("Players")
|
local Players: Players = game:GetService("Players")
|
||||||
local Storage = game:GetService("ReplicatedStorage")
|
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||||
local RS = game:GetService("RunService") :: RunService
|
local RS: RunService = game:GetService("RunService")
|
||||||
|
|
||||||
local ClientStorage = Storage:WaitForChild("Client")
|
local ClientStorage = Storage:WaitForChild("Client")
|
||||||
local LoadCompleted = ClientStorage:WaitForChild("LoadingComplete")
|
local LoadCompleted = ClientStorage:WaitForChild("LoadingComplete")
|
||||||
@@ -19,11 +19,11 @@ local KeyBindsModule = require(ClientStorage:WaitForChild("KeyBinds"))
|
|||||||
local CameraSettings = require(ClientStorage:WaitForChild("Camera"))
|
local CameraSettings = require(ClientStorage:WaitForChild("Camera"))
|
||||||
|
|
||||||
local Player = Players.LocalPlayer
|
local Player = Players.LocalPlayer
|
||||||
local PlayerGui = Player:WaitForChild("PlayerGui")
|
local PlayerGui = Player:WaitForChild("PlayerGui") :: PlayerGui
|
||||||
|
|
||||||
--We need to wait for the game to load before spamming functionality
|
--We need to wait for the game to load before spamming functionality
|
||||||
repeat
|
repeat
|
||||||
local GameIsLoaded = LoadCompleted:Invoke()
|
local GameIsLoaded = (LoadCompleted :: BindableFunction):Invoke()
|
||||||
task.wait()
|
task.wait()
|
||||||
until GameIsLoaded
|
until GameIsLoaded
|
||||||
|
|
||||||
@@ -41,10 +41,10 @@ local Crosshair = CrosshairSettings.constructor(PlayerGui)
|
|||||||
local function CameraBinds()
|
local function CameraBinds()
|
||||||
local CameraBindMap = KeyBindsModule.constructor(false)
|
local CameraBindMap = KeyBindsModule.constructor(false)
|
||||||
|
|
||||||
CameraBindMap:AddInputBegan({Enum.KeyCode.C, Enum.KeyCode.Z}, function()
|
CameraBindMap:AddInputBegan({Enum.KeyCode.C, Enum.KeyCode.Z}, function(_KeyPressed)
|
||||||
Camera:ZoomIn(Vignette, Crosshair)
|
Camera:ZoomIn(Vignette, Crosshair)
|
||||||
end)
|
end)
|
||||||
CameraBindMap:AddInputEnded({Enum.KeyCode.C, Enum.KeyCode.Z}, function()
|
CameraBindMap:AddInputEnded({Enum.KeyCode.C, Enum.KeyCode.Z}, function(_KeyPressed)
|
||||||
Camera:ZoomOut(Vignette, Crosshair)
|
Camera:ZoomOut(Vignette, Crosshair)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ local EditorEntities = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type HideEditor = (a1: BasePart | Folder, a2: boolean) -> ()
|
type HideEditor = (a1: BasePart | Folder, a2: boolean) -> ()
|
||||||
|
type LuaChangeableContainer = Script | LocalScript
|
||||||
|
|
||||||
function StudioEntities.indexAll(enabled: boolean): Entities
|
function StudioEntities.indexAll(enabled: boolean): Entities
|
||||||
if #StudioEntities.IndexedEntities == 0 then
|
if #StudioEntities.IndexedEntities == 0 then
|
||||||
@@ -88,7 +89,7 @@ function StudioEntities.indexAll(enabled: boolean): Entities
|
|||||||
|
|
||||||
if not Players:GetPlayerFromCharacter(Model) then
|
if not Players:GetPlayerFromCharacter(Model) then
|
||||||
pcall(function()
|
pcall(function()
|
||||||
Item.Enabled = false
|
(Item :: LuaChangeableContainer).Enabled = false
|
||||||
end)
|
end)
|
||||||
Item:Destroy()
|
Item:Destroy()
|
||||||
warn(`Script: "{Item.Name}" ({Item.ClassName}) was removed because it was outside of the rhpid-framework boundries,`, Item:GetFullName())
|
warn(`Script: "{Item.Name}" ({Item.ClassName}) was removed because it was outside of the rhpid-framework boundries,`, Item:GetFullName())
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ local function Clouds(): Clouds
|
|||||||
end
|
end
|
||||||
|
|
||||||
export type exports = {
|
export type exports = {
|
||||||
Sky: Sky,
|
Sky: () -> Sky,
|
||||||
Atmosphere: Atmosphere,
|
Atmosphere: () -> Atmosphere,
|
||||||
Clouds: Clouds,
|
Clouds: () -> Clouds,
|
||||||
}
|
}
|
||||||
|
|
||||||
local export: exports = {
|
local export: exports = {
|
||||||
|
|||||||
@@ -7,37 +7,34 @@
|
|||||||
local BindLink = {}
|
local BindLink = {}
|
||||||
BindLink.__index = BindLink
|
BindLink.__index = BindLink
|
||||||
|
|
||||||
local UIS = game:GetService("UserInputService")
|
|
||||||
|
|
||||||
export type KeyBindMap = {
|
export type KeyBindMap = {
|
||||||
[string]: {
|
[string]: {
|
||||||
[Enum.KeyCode]: () -> ()
|
[Enum.KeyCode]: (KeyPressed: Enum.KeyCode) -> ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export type InputBegan = RBXScriptConnection
|
export type InputBegan = RBXScriptConnection
|
||||||
export type InputEnded = RBXScriptConnection
|
export type InputEnded = RBXScriptConnection
|
||||||
|
|
||||||
type CallbackFunction = () -> ()
|
type CallbackFunction = () -> ()
|
||||||
|
type BindConstructor = {
|
||||||
|
BindMap: KeyBindMap,
|
||||||
|
InputBegan: InputBegan,
|
||||||
|
InputEnded: InputEnded
|
||||||
|
}
|
||||||
|
|
||||||
|
local UIS = game:GetService("UserInputService")
|
||||||
|
|
||||||
function BindLink.constructor(gameProcessing: boolean) --Allow multiple bindings of the same keys, no overwrites
|
function BindLink.constructor(gameProcessing: boolean) --Allow multiple bindings of the same keys, no overwrites
|
||||||
type BindConstructor = {
|
|
||||||
BindMap: KeyBindMap,
|
|
||||||
InputBegan: InputBegan,
|
|
||||||
InputEnded: InputEnded
|
|
||||||
}
|
|
||||||
|
|
||||||
local self = {} :: BindConstructor
|
local self = {} :: BindConstructor
|
||||||
self.BindMap = {
|
self.BindMap = {
|
||||||
Began = {},
|
Began = {},
|
||||||
Ended = {}
|
Ended = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
--Return these for convenience
|
--Return these for convenience
|
||||||
self.InputBegan = UIS.InputBegan:Connect(function(input, gameProcessedEvent)
|
self.InputBegan = UIS.InputBegan:Connect(function(input, gameProcessedEvent)
|
||||||
if gameProcessing and gameProcessedEvent or not gameProcessedEvent then
|
if gameProcessing and gameProcessedEvent or not gameProcessedEvent then
|
||||||
local switch = self.BindMap.Began[input.KeyCode]
|
local switch = self.BindMap.Began[input.KeyCode]
|
||||||
if switch then
|
if switch then
|
||||||
switch()
|
switch(input.KeyCode)
|
||||||
else
|
else
|
||||||
--switch.default()
|
--switch.default()
|
||||||
end
|
end
|
||||||
@@ -47,7 +44,7 @@ function BindLink.constructor(gameProcessing: boolean) --Allow multiple bindings
|
|||||||
if gameProcessing and gameProcessedEvent or not gameProcessedEvent then
|
if gameProcessing and gameProcessedEvent or not gameProcessedEvent then
|
||||||
local switch = self.BindMap.Ended[input.KeyCode]
|
local switch = self.BindMap.Ended[input.KeyCode]
|
||||||
if switch then
|
if switch then
|
||||||
switch()
|
switch(input.KeyCode)
|
||||||
else
|
else
|
||||||
--switch.default()
|
--switch.default()
|
||||||
end
|
end
|
||||||
@@ -60,7 +57,6 @@ end
|
|||||||
function BindLink:AddInputBegan(Keys: {Enum.KeyCode}, Callback: CallbackFunction)
|
function BindLink:AddInputBegan(Keys: {Enum.KeyCode}, Callback: CallbackFunction)
|
||||||
for i = 1, #Keys do
|
for i = 1, #Keys do
|
||||||
local Key = Keys[i]
|
local Key = Keys[i]
|
||||||
|
|
||||||
if self.BindMap.Began[Key] then
|
if self.BindMap.Began[Key] then
|
||||||
warn(`Key >began< "{Key.Name}" is already binded on this KeyBind map`, debug.traceback())
|
warn(`Key >began< "{Key.Name}" is already binded on this KeyBind map`, debug.traceback())
|
||||||
end
|
end
|
||||||
@@ -71,7 +67,6 @@ end
|
|||||||
function BindLink:AddInputEnded(Keys: {Enum.KeyCode}, Callback: CallbackFunction)
|
function BindLink:AddInputEnded(Keys: {Enum.KeyCode}, Callback: CallbackFunction)
|
||||||
for i = 1, #Keys do
|
for i = 1, #Keys do
|
||||||
local Key = Keys[i]
|
local Key = Keys[i]
|
||||||
|
|
||||||
if self.BindMap.Ended[Key] then
|
if self.BindMap.Ended[Key] then
|
||||||
warn(`Key >ended< "{Key.Name}" is already binded on this KeyBind map`, debug.traceback())
|
warn(`Key >ended< "{Key.Name}" is already binded on this KeyBind map`, debug.traceback())
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user