working but roblox bug and fix respawning issues on the client

This commit is contained in:
2024-04-22 20:12:48 -04:00
parent 431ec165b8
commit cb0d1d44dc
6 changed files with 56 additions and 51 deletions

View File

@@ -2,43 +2,44 @@
--!native
--!strict
type UDP = UnreliableRemoteEvent
type TCP = RemoteEvent
type inherented = any
type CurrentCamera = Camera
type UDP = UnreliableRemoteEvent
type TCP = RemoteEvent
type inherented = any
type CurrentCamera = Camera
type CharacterShared = Folder
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
type Impl_Constructor = {
__index: Impl_Constructor,
constructor: Constructor_Fun,
--Class functions
EnableSneak: (self: ClassConstructor) -> (),
DisableSneak: (self: ClassConstructor) -> (),
EnableCrouch: (self: ClassConstructor) -> (),
DisableCrouch: (self: ClassConstructor) -> (),
EnableSneak: (self: ClassConstructor) -> (),
DisableSneak: (self: ClassConstructor) -> (),
EnableCrouch: (self: ClassConstructor) -> (),
DisableCrouch: (self: ClassConstructor) -> (),
EnableFlashlight: (self: ClassConstructor, FlashlightKey: Enum.KeyCode) -> (),
DisableFlashlight: (self: ClassConstructor, FlashlightKey: Enum.KeyCode) -> (),
ToggleFlashlight: (self: ClassConstructor, FlashlightKey: Enum.KeyCode) -> ()
} & Impl_Static_Props
type Constructor_Fun = (HumanoidSettings: inherented, CurrentCamera: CurrentCamera, ActionsTCP: TCP) -> ClassConstructor
type Constructor_Fun = (CharacterShared: CharacterShared, HumanoidSettings: inherented, CurrentCamera: CurrentCamera, ActionsTCP: TCP) -> ClassConstructor
type Impl_Static_Props = {
DoingAction: boolean,
Sneaking: boolean,
Crouching: boolean,
Walk: number,
SneakingSpeed: number,
StandHeight: number,
CrouchHeight: number,
DoingAction: boolean,
Sneaking: boolean,
Crouching: boolean,
Walk: number,
SneakingSpeed: number,
StandHeight: number,
CrouchHeight: number,
WalkSpeedMultiplier: number,
CrouchSpeed: number,
FlashlightEnabled: boolean
CrouchSpeed: number,
FlashlightEnabled: boolean
}
type Constructor_Return_Props = {
Humanoid: Humanoid,
Humanoid: Humanoid,
HumanoidSettings: any,
CurrentCamera: CurrentCamera,
ActionsTCP: TCP
CurrentCamera: CurrentCamera,
ActionsTCP: TCP
}
export type ActionsConstructor = ClassConstructor
@@ -61,22 +62,20 @@ Actions.CrouchSpeed = .2
--Flashlight static properties
Actions.FlashlightEnabled = false
local CharacterShared = _G.include(script, "CharacterShared")
local FlashlightRemote: UDP = CharacterShared:WaitForChild("Flashlight")
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
local Storage = game:GetService("ReplicatedStorage")
local Tween = require(Storage:WaitForChild("Tween"))
local Delta = require(Storage:WaitForChild("Delta"))
local CrouchTween = Tween.constructor()
function Actions.constructor(HumanoidSettings: inherented, CurrentCamera: CurrentCamera, ActionsTCP: TCP)
function Actions.constructor(CharacterShared, HumanoidSettings, CurrentCamera, ActionsTCP)
return setmetatable({
Humanoid = HumanoidSettings.Humanoid,
FlashlightRemote = CharacterShared:WaitForChild("Flashlight"),
Humanoid = HumanoidSettings.Humanoid,
HumanoidSettings = HumanoidSettings,
CurrentCamera = CurrentCamera,
ActionsTCP = ActionsTCP
CurrentCamera = CurrentCamera,
ActionsTCP = ActionsTCP
}, Actions)
end
@@ -128,7 +127,7 @@ function Actions:EnableFlashlight(FlashlightKey)
local c = table.pack(self.CurrentCamera.CFrame:ToEulerAnglesXYZ())
table.insert(c, c.n)
FlashlightRemote:FireServer(c)
self.FlashlightRemote:FireServer(c)
Delta:time()
end
end)

View File

@@ -14,10 +14,11 @@ local HumanoidModule = require(script:WaitForChild("Humanoid"))
local SpineModule = require(script:WaitForChild("SpineKinematics"))
local ActionsModule = require(script:WaitForChild("Actions"))
type Character = Model
type Character = Model
type HumanoidRootPart = BasePart
type TCP = RemoteEvent
type CurrentCamera = Camera
type TCP = RemoteEvent
type CurrentCamera = Camera
type CharacterShared = Folder
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
type Impl_Constructor = {
@@ -43,6 +44,7 @@ type Impl_Static_Props = {
type Constructor_Fun = (Character: Character) -> ClassConstructor
type Constructor_Return_Props = {
CharacterShared: CharacterShared,
ActionsTCP: TCP,
CurrentCamera: CurrentCamera,
HRPSettings: HumanoidRPSettings.HumanoidRPSettingsConstructor,
@@ -71,17 +73,17 @@ CharacterModule.KeyBinds = {
}
function CharacterModule.constructor(Character)
local CharacterShared = Character:WaitForChild("shared") :: Folder
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart") :: HumanoidRootPart
local Humanoid = Character:WaitForChild("Humanoid") :: Humanoid
local self = {} :: Constructor_Return_Props
self.CharacterShared = Character:WaitForChild("shared") :: Folder
self.CurrentCamera = workspace.CurrentCamera
self.ActionsTCP = CharacterShared:WaitForChild("Actions") :: TCP
self.ActionsTCP = self.CharacterShared:WaitForChild("Actions") :: TCP
self.HRPSettings = HumanoidRPSettings.constructor(HumanoidRootPart)
self.CameraConsturctor = CameraModule.constructor(self.CurrentCamera, HumanoidRootPart, Humanoid)
self.HumanoidSettings = HumanoidModule.constructor(Humanoid)
self.SpineMovement = SpineModule.constructor(CharacterShared, self.CurrentCamera)
self.SpineMovement = SpineModule.constructor(self.CharacterShared, self.CurrentCamera)
pcall(table.clear, _G)
pcall(table.freeze, _G)
@@ -93,7 +95,7 @@ end
function CharacterModule:CharacterKeyBinds()
local ClientBindMap = BindModule.constructor(false)
local Actions = ActionsModule.constructor(self.HumanoidSettings, self.CurrentCamera, self.ActionsTCP)
local Actions = ActionsModule.constructor(self.CharacterShared, self.HumanoidSettings, self.CurrentCamera, self.ActionsTCP)
--Crouch
ClientBindMap:AddInputBegan(CharacterModule.KeyBinds.Crouch, function(_KeyPressed)

View File

@@ -30,12 +30,12 @@ CrosshairModule.__index = CrosshairModule
--Use a custom crosshair so we can do effects to it
CrosshairModule.Icon = "rbxassetid://12643750723"
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
local Storage = game:GetService("ReplicatedStorage")
local Easings = require(Storage:WaitForChild("Algebra"))
function CrosshairModule.constructor(PlayerGui: PlayerGui)
local Screen = PlayerGui:WaitForChild("Crosshair") :: ScreenGui
local Icon = Screen:WaitForChild("ImageLabel") :: ImageLabel
local Icon = Screen:WaitForChild("ImageLabel") :: ImageLabel
return setmetatable({
Screen = Screen,
Icon = Icon

View File

@@ -9,10 +9,10 @@ local Storage = game:GetService("ReplicatedStorage")
local RS = game:GetService("RunService")
--Production--
--if not RS:IsStudio() then
RS.RenderStepped:Wait()
if not RS:IsStudio() then
task.wait(.5)
script.Parent.Parent = nil
--end
end
--
local UI = script:WaitForChild("UI")
@@ -58,9 +58,6 @@ local Vignette = VignetteSettings.constructor(PlayerGui)
local Camera = CameraSettings.constructor(CurrentCamera, Player)
local Crosshair = CrosshairSettings.constructor(PlayerGui)
LoadCharacter(PlayerCharacter)
Player.CharacterAdded:Connect(LoadCharacter)
--Keybinds
local function CameraBinds()
local CameraBindMap = KeyBindsModule.constructor(false)
@@ -74,8 +71,8 @@ local function CameraBinds()
end
local function Crosshair3DEffect()
local RootVelocity = Instance.new("BindableEvent") :: BindableEvent
RootVelocity.Name = "RootVelocity"
local RootVelocity = Instance.new("BindableEvent") :: BindableEvent
RootVelocity.Name = "RootVelocity"
RootVelocity.Parent = ClientStorage
RootVelocity.Event:Connect(function(RootVelocity: Vector3)
@@ -90,4 +87,7 @@ Crosshair:Enable()
HealthSettings:Enable()
CameraBinds()
Crosshair3DEffect()
Crosshair3DEffect()
LoadCharacter(PlayerCharacter)
Player.CharacterAdded:Connect(LoadCharacter)

View File

@@ -8,8 +8,12 @@ type Users = {
}
local Users = {
Admin = {},
Banned = {}
Admin = {
0
},
Banned = {
0
}
}
return Users