ADVERTISEMENTREMOVE ADS
Game icon

laydown script by me😋

QiaoChen_1's Place
3 weeks ago
Script preview thumbnail
Script Preview

Description

!!!!!!!!!!!!!!!!!!!!

press L to laydown

no ui ea

can use in every game

ADVERTISEMENTREMOVE ADS
77 Lines • 2.34 KiB
Raw
--!!!!!!!!!!!!!!!!!!!!press L to laydown
-- 本地脚本,放在StarterPlayerScripts中
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
local isLying = false
local originalCFrame -- 存储原始位置和旋转
local originalStateSettings = {} -- 存储原始状态设置
-- 躺下函数
local function lieDown()
if isLying then return end
isLying = true
-- 保存原始状态
originalCFrame = rootPart.CFrame
-- 保存原始状态设置,用于后续恢复
originalStateSettings.GettingUp = humanoid:GetStateEnabled(Enum.HumanoidStateType.GettingUp)
originalStateSettings.Physics = humanoid:GetStateEnabled(Enum.HumanoidStateType.Physics)
-- 禁用移动和自动状态恢复
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
humanoid.AutoRotate = false -- 禁用自动旋转
-- 关键:禁用"起身"和"物理"状态,防止Humanoid自动纠正姿势
humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Physics, false)
-- 让角色平躺(旋转90度并稍微下沉)
rootPart.CFrame = originalCFrame *
CFrame.Angles(math.rad(90), 0, 0) * -- 旋转90度平躺
CFrame.new(0, -1, 0) -- 稍微下沉贴近地面
end
-- 站起来函数
local function standUp()
if not isLying then return end
isLying = false
-- 恢复原始状态
rootPart.CFrame = originalCFrame
-- 恢复移动能力和状态设置
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
humanoid.AutoRotate = true
-- 恢复原始状态设置
humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, originalStateSettings.GettingUp)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Physics, originalStateSettings.Physics)
end
-- 按L键切换躺/站状态
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if not gameProcessed and input.KeyCode == Enum.KeyCode.L then
if isLying then
standUp()
else
lieDown()
end
end
end)
-- 角色重生时重置
player.CharacterAdded:Connect(function(newCharacter)
character = newCharacter
humanoid = character:WaitForChild("Humanoid")
rootPart = character:WaitForChild("HumanoidRootPart")
isLying = false
originalStateSettings = {}
end)
warn("script execute😍")
ADVERTISEMENTREMOVE ADS

Comments

0 comments
to add a comment
Loading comments
ADVERTISEMENTREMOVE ADS