Script issue 2. Need help

Hello, I’m Adam

I’m a beginner scripter, so please don’t make fun of my scripting skills.

i would like to disable the camera bobbing whenever i want.
Code:

-- The code is here. If you help me to how to disable it on jumps / landings it will be cool.
local Humanoid = script.Parent:FindFirstChild("Humanoid")
local Character = script.Parent

Humanoid.Jump:Connect(function()
	script.Parent:WaitForChild("CameraBobbing").Disabled = true
end)

Humanoid.FallingDown:Connect(function()
	script.Parent:WaitForChild("CameraBobbing").Disabled = false
end)

It’s supposed to be Humanoid.Jumped, but even that doesn’t work properly, so i recommend using :GetPropertyChangedSignal("Jump")

local Humanoid = script.Parent:FindFirstChild("Humanoid")
local Character = script.Parent

Humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
	script.Parent:WaitForChild("CameraBobbing").Disabled = true
end)

Humanoid.FallingDown:Connect(function()
	script.Parent:WaitForChild("CameraBobbing").Disabled = false
end)

I will take a look. Thank you.

Ok so the edited line works, theres no problem with that.

but i want to enable the camera bobbing when my character lands on the baseplate

Oh, sorry. I believe just using the :GetPropertyChangedSignal should work better here.

local Humanoid = script.Parent:FindFirstChild("Humanoid")
local Character = script.Parent

Humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
	if Humanoid.Jump then
		script.Parent:WaitForChild("CameraBobbing").Disabled = true
	else
		script.Parent:WaitForChild("CameraBobbing").Disabled = false
	end
end)

Let me take a look. Ok im copying it.

No it didnt worked. Also i put this Script into SCS it will work?

Are you still here? still waiting

https://developer.roblox.com/en-us/api-reference/event/Humanoid/StateChanged

Use StateChanged instead, it’s fitted for this purpose.

Hmmm. Let me look into this. Cool

task.wait()
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local CameraBob = Character:WaitForChild("CameraBobbing")

Humanoid.StateChanged:Connect(function(NewState)
	if NewState == Enum.HumanoidStateType.Jumping then
		CameraBob.Disabled = true
	elseif NewState == Enum.HumanoidStateType.FallingDown then
		CameraBob.Disabled = false
	end
end)

I’m not sure what “CameraBobbing” is here, I assume it’s a script.

1 Like

Thanks. it fixed my problem. have a nice day.