mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
crouching and move Humanoid.lua from server to client
This commit is contained in:
31
src/client/Character/Client/Crouch.lua
Normal file
31
src/client/Character/Client/Crouch.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
local CrouchModule = {
|
||||
StandHeight = 2.1,
|
||||
CrouchHeight = .6
|
||||
}
|
||||
CrouchModule.__index = CrouchModule
|
||||
|
||||
local Tween = require(game:GetService("ReplicatedStorage"):WaitForChild("Tween"))
|
||||
|
||||
function CrouchModule.constructor(Humanoid: Humanoid)
|
||||
return setmetatable({
|
||||
Humanoid = Humanoid
|
||||
}, CrouchModule)
|
||||
end
|
||||
|
||||
local CrouchTween = Tween.constructor()
|
||||
|
||||
function CrouchModule:Crouch(StandingWalkSpeed: number)
|
||||
CrouchTween:Start(self.Humanoid, {
|
||||
HipHeight = CrouchModule.CrouchHeight,
|
||||
WalkSpeed = StandingWalkSpeed-6
|
||||
}, TweenInfo.new(.4))
|
||||
end
|
||||
|
||||
function CrouchModule:Stand(CrouchingWalkSpeed: number)
|
||||
CrouchTween:Start(self.Humanoid, {
|
||||
HipHeight = CrouchModule.StandHeight,
|
||||
WalkSpeed = CrouchingWalkSpeed+6
|
||||
}, TweenInfo.new(.2))
|
||||
end
|
||||
|
||||
return CrouchModule
|
||||
@@ -1,5 +1,11 @@
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
local ClientStorage = Storage:WaitForChild("Client")
|
||||
|
||||
local HumanoidRPSettings = require(script:WaitForChild("HumanoidRootPart"))
|
||||
local CameraModule = require(script:WaitForChild("Camera"))
|
||||
local CrouchModule = require(script:WaitForChild("Crouch"))
|
||||
local BindModule = require(ClientStorage:WaitForChild("KeyBinds"))
|
||||
local HumanoidModule = require(script:WaitForChild("Humanoid"))
|
||||
|
||||
local Character = script.Parent
|
||||
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
|
||||
@@ -8,6 +14,22 @@ local CurrentCamera = workspace.CurrentCamera
|
||||
|
||||
local HRPSettings = HumanoidRPSettings.constructor(HumanoidRootPart)
|
||||
local CameraConsturctor = CameraModule.constructor(CurrentCamera, HumanoidRootPart, Humanoid)
|
||||
local HumanoidSettings = HumanoidModule.constructor(Humanoid)
|
||||
|
||||
local function CrouchFeature()
|
||||
local CrouchConstructor = CrouchModule.constructor(Humanoid)
|
||||
local CourchBindMap = BindModule.constructor()
|
||||
|
||||
CourchBindMap:AddInputBegan({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function()
|
||||
CrouchConstructor:Crouch(10)
|
||||
end)
|
||||
CourchBindMap:AddInputEnded({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function()
|
||||
CrouchConstructor:Stand(5)
|
||||
end)
|
||||
end
|
||||
|
||||
HumanoidSettings:SetWalkSpeed(10)
|
||||
HRPSettings:DisableRobloxSounds()
|
||||
CameraConsturctor:EnableBobbing()
|
||||
CameraConsturctor:EnableBobbing()
|
||||
|
||||
CrouchFeature()
|
||||
@@ -1,15 +1,10 @@
|
||||
local Character = script.Parent
|
||||
|
||||
local Shadows = require(script:WaitForChild("Shadows"))
|
||||
local HumanoidModule = require(script:WaitForChild("Humanoid"))
|
||||
|
||||
local Humanoid = Character:WaitForChild("Humanoid")
|
||||
local Shadows = require(script:WaitForChild("Shadows"))
|
||||
|
||||
local CharacterShadows = Shadows.constructor(Character)
|
||||
local HumanoidSettings = HumanoidModule.constructor(Humanoid)
|
||||
|
||||
CharacterShadows:off() --I plan to have 2 player support and characters block a ton of light
|
||||
HumanoidSettings:SetWalkSpeed(10)
|
||||
|
||||
Character.DescendantAdded:Connect(function(Instance)
|
||||
task.wait() --Wait for the instance to properly replicate?
|
||||
|
||||
Reference in New Issue
Block a user