Hello! Why are these two if statements not working?
if Rope.Length ~= 2 then
if Rope.Length ~= 30 then
script:
local hrpAttachment
local RopeAttachment
local Rope
local RopeSpawned = false
local RopeLength = 5
local RsLongerYes
local RsShorterYes
local function DestroyRope()
if RopeSpawned == true then
Rope.Parent = nil
RopeAttachment.Parent = nil
hrpAttachment = nil
RopeAttachment = nil
CAS:UnbindAction("DestroyRope")
RopeSpawned = false
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
humanoid.WalkSpeed = 21
end
end
local function FindGrapplePart()
for i, v in pairs(workspace.GrappleParts:GetChildren()) do
if v:IsA("BasePart") then
if (hrp.Position - v.Position).magnitude < GrappleDistance then
far = (hrp.Position - v.Position)
GrapplePart = v
end
end
end
end
rs:BindToRenderStep("ClosestGrapPart", 1, FindGrapplePart)
local function IsOnGround()
if humanoid.FloorMaterial ~= Enum.Material.Air then
DestroyRope()
rs:UnbindFromRenderStep("IsOnGround")
humanoid:ChangeState(Enum.HumanoidStateType.Landed)
rs:UnbindFromRenderStep("RopeLong")
rs:UnbindFromRenderStep("RopeShort")
end
end
local function Grapple()
if humanoid.FloorMaterial == Enum.Material.Air and RopeSpawned == false and GrapplePart ~= nil and (hrp.Position - GrapplePart.Position).magnitude < GrappleDistance then
hrpAttachment = Instance.new("Attachment")
hrpAttachment.Parent = hrp
RopeAttachment = Instance.new("Attachment")
RopeAttachment.Parent = GrapplePart
Rope = Instance.new("RopeConstraint")
Rope.Parent = workspace
Rope.Visible = true
Rope.Length = (hrp.Position - GrapplePart.Position).magnitude
Rope.Attachment0 = hrpAttachment
Rope.Attachment1 = RopeAttachment
RopeSpawned = true
SpinJumpDB = false
CAS:BindAction("DestroyRope", DestroyRope, false, Enum.KeyCode.Space)
CAS:UnbindAction("groundpound")
humanoid.WalkSpeed = 40
rs:BindToRenderStep("IsOnGround", 1, IsOnGround)
end
end
local function RopeShorter()
if Rope.Length ~= 30 then
Rope.Length = Rope.Length - .099
end
end
local function RopeLonger()
if Rope.Length ~= 2 then
Rope.Length = Rope.Length + .099
end
end
UIS.InputBegan:Connect(function(input)
if RopeSpawned == true and input.KeyCode == Enum.KeyCode.F then
rs:BindToRenderStep("RopeLong", 1, RopeLonger)
end
end)
UIS.InputEnded:Connect(function(input)
if RopeSpawned == true and input.KeyCode == Enum.KeyCode.F then
rs:UnbindFromRenderStep("RopeLong")
end
end)
UIS.InputBegan:Connect(function(input)
if RopeSpawned == true and input.KeyCode == Enum.KeyCode.G then
rs:BindToRenderStep("RopeShort", 1, RopeShorter)
end
end)
UIS.InputEnded:Connect(function(input)
if RopeSpawned == true and input.KeyCode == Enum.KeyCode.G then
rs:UnbindFromRenderStep("RopeShort")
end
end)
CAS:BindAction("Grapple", Grapple, false, Enum.KeyCode.E)
also is there any other better way of making a grappling hook?