#How to prevent camera from going back up while im still crouched?
68 messages · Page 1 of 1 (latest)
i have the output in the video and its fine as far as im aware
Maybe u are not as aware as you are fine
Idk xd
Im not on pc sadly
So csnt code
Wait its 2023
Forgot
function crouch()
local humanoid = character:FindFirstChild("Humanoid")
local goal = {}
if humanoid then
if crouching == false then
goal.CameraOffset = Vector3.new(0,0,0)
elseif crouching == true then
goal.CameraOffset = Vector3.new(0,-2.5,0)
end
end
local crouchTween = TweenService:Create(humanoid,crouchTweenInfo,goal)
crouchTween:Play()
end
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if gameProcessedEvent then return end
if input.KeyCode == Enum.KeyCode[keybind] then
if crouching then
humanoid.WalkSpeed = 10
crouching = false
print(crouching)
crouch()
script.Parent.up:Play()
character.HumanoidRootPart.CanCollide = true
else
humanoid.WalkSpeed = 4
crouching = true
print(crouching)
crouch()
script.Parent.down:Play()
character.HumanoidRootPart.CanCollide = false
end
end
end)
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
humanoid:GetPropertyChangedSignal("CameraOffset"):Connect(function()
if crouching == true then
humanoid.CameraOffset = Vector3.new(0,-2.5,0)
end
end)
end
@zenith cave can u tell me if this helps u debugging ur problem?
I asked the ai to edit ur code in a way to help debugging, since im on phone, but i think the Ai did something wrong
lmao
Maybe u forgot lua markdown
oh wait yeah i did
Not like I can see it colored anyway since im on mobile
also probably wont work because I didnt define any variables in my sample that i posted here but ill try it anyway lol
It just used the variables from ur code
Probably
Idk what he did , cant read, i told him something but probably he did something else
yeah all it did was add
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
humanoid:GetPropertyChangedSignal("CameraOffset"):Connect(function()
if crouching == true then
humanoid.CameraOffset = Vector3.new(0,-2.5,0)
end
end)
end
and nothing changed when i texted
tested*
Yes... never gonna ask chatGPT to code anything ever again...
😭
Well im home in one hour
well when you're home if you wanna help then feel free
i might not be online so if you wanna try the code yourself here it is
local keybind = "LeftShift"
local animationId = 8387703587
crouchTweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local UserInputService = game:GetService("UserInputService")
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
TweenService = game:GetService("TweenService")
local animation = Instance.new("Animation")
animation.AnimationId = 'rbxassetid://' .. animationId
local animationTrack = humanoid:WaitForChild("Animator"):LoadAnimation(animation)
animationTrack.Priority = Enum.AnimationPriority.Action
local crouching = false
function crouch()
local humanoid = character:FindFirstChild("Humanoid")
local goal = {}
if humanoid then
if crouching == false then
goal.CameraOffset = Vector3.new(0,0,0)
elseif crouching == true then
goal.CameraOffset = Vector3.new(0,-2.5,0)
end
end
local crouchTween = TweenService:Create(humanoid,crouchTweenInfo,goal)
crouchTween:Play()
end
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if gameProcessedEvent then return end
if input.KeyCode == Enum.KeyCode[keybind] then
if crouching then
humanoid.WalkSpeed = 10
crouching = false
print(crouching)
crouch()
--animationTrack:Stop()
script.Parent.up:Play()
character.HumanoidRootPart.CanCollide = true
else
humanoid.WalkSpeed = 4
crouching = true
print(crouching)
crouch()
--animationTrack:Play()
script.Parent.down:Play()
character.HumanoidRootPart.CanCollide = false
end
end
end)```
local script in starterCharacterScripts
Ok later
** You are now Level 4! **
Im not on my pc
Ok
thanks man
works kinda
doesnt tween quite right but camera works
i cant actually fit under small spaces though
yea collissions are still the same
Well u almost did it urself
Here
yea not sure why the tween works like that though
