How do i stop truss pushing player backward when player jumps ?
Hello,
To keep everything simple and clear, i just want to know how can i stop a truss pushing player backward when player jumps (like, a vertical trussjump or something).
Games such as Obby King or Flood Escape 2 Already have this physic but idk how it works
Hope you can help me
Thanks
I am guessing they set the Humanoid State to Jumping when they Jump while they are Clmbling.
Example script (StarterPlayerScripts)
local Player = game:GetService("Players").LocalPlayer
local UserInputService = game:GetService("UserInputService")
UserInputService.JumpRequest:Connect(function()
local Character = Player.Character
if not Character then
return
end
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
if not Humanoid then
return
end
if Humanoid:GetState() == Enum.HumanoidStateType.Climbing then
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
end)
i found a way to do what i want but it’s a bit glitched…
wait(script.Parent)
local Character = script.Parent
local d = true
local Humanoid = Character:FindFirstChildOfClass("Humanoid") or Character:WaitForChild("Humanoid")
local UserInputService = game:GetService("UserInputService")
game:GetService("RunService").Heartbeat:Connect(function()
if Humanoid:GetState() == Enum.HumanoidStateType.Climbing and not d then
Humanoid.JumpPower = 40
local b = Instance.new("BodyForce", Character.HumanoidRootPart)
b.Force = Vector3.new(0, 8000, 0)
spawn(function()
wait(.05)
b:Destroy()
end)
d = true
else
Humanoid.JumpPower = 50
end
end)
UserInputService.JumpRequest:Connect(function()
if Humanoid:GetState() == Enum.HumanoidStateType.Climbing then
d = false
end
end)
I decided to test my code and it didn’t work…
So I decided to make a new version (In StarterCharacterScripts).
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid") :: Humanoid
local h = Character:WaitForChild("HumanoidRootPart")
local Force = Instance.new("VectorForce", h)
Force.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
Force.Attachment0 = Instance.new("Attachment", h)
Force.Force = Vector3.new(0,0,-2000)
Force.Enabled = false
local Connection = Humanoid.StateChanged:Connect(function(old, new)
if old == Enum.HumanoidStateType.Climbing and new == Enum.HumanoidStateType.Jumping then
Force.Enabled = true
task.wait(.16)
Force.Enabled = false
end
end)
Humanoid.Died:Once(function()
Connection:Disconnect()
Connection = nil
end)