As read in the title, my camera offset is reset immediately without the value changing upon changing it. i tried looking for other people with this issue but no one seems to have found the solution
Post all of the code before and after this line as well, posting just one line won’t help for mistakes in code structuring. Also preferably explain in detail what you are trying to accomplish and what situations the camera offset needs to be changed.
the thing is, theres a lot of code so i have to do some condensing
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Crouch = Humanoid:LoadAnimation(script:WaitForChild("Crouch"))
local Camera = workspace.CurrentCamera
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local RunsService = game:GetService("RunService")
local Walking = false
local Debounce = false
local Crouching = false
distance = 0.4
speed = 4
Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
if Humanoid.MoveDirection.Magnitude > 0 then
if Walking == false then
Walking = true
Crouch:AdjustSpeed(1)
end
else
if Walking == true then
Walking = false
Crouch:AdjustSpeed(0)
end
end
end)
UIS.InputBegan:Connect(function(input,istyping)
if not istyping and input.KeyCode == Enum.KeyCode.C then
if Walking then
if not Crouching then
Humanoid.WalkSpeed = 9
Humanoid.CameraOffset = Vector3.new(0,-2,0) ------ camera offset
Crouching = true
script.Crouch1:Play()
Crouch:Play()
else
Humanoid.CameraOffset=Vector3.new(0,0,0) ------ camera offset
script.Crouch1:Play()
Humanoid.WalkSpeed = 14
Crouching = false
Crouch:Stop()
end
end
end
end)