How do i make the player unable to Parachute while they are Rope Swinging? (Separate LocalScripts)

I want to have a way in order to disable Rope Swinging while I’m Parachuting, and vise versa. My issue is, is that i have tried many ways and they usually just straight up don’t work and I’m not entirely sure why. I have tried remote events, Bindable events, just merging the two Scripts into one, etc, etc, but none of the solutions have worked for me since usually it breaks when i try.

This is my parachute code

humanoid.StateChanged:Connect(function(old, new)
	
	if new == Enum.HumanoidStateType.Freefall then
		wait(0.5)
		if humanoid.FloorMaterial == Enum.Material.Air then
			paraready = true
			print("Parachute ready!")
		end
	end
	
	if new == Enum.HumanoidStateType.Landed and chuting == true then
		animtrack3:Play()
		paraready = false
		chuting = false
	end
end)

UserInputService.InputBegan:Connect(function(input, gameProcessed)

	if input.KeyCode == Enum.KeyCode.Space and paraready == true and chuting == false and alive == true then
		local Para = Parachute:Clone()
		Para.Parent = workspace
		Para:SetPrimaryPartCFrame(root.CFrame + Vector3.new(0, -8, 0))
		local Weld = Instance.new("Weld")
		local orientation = root.Orientation
		Weld.Parent = Para.PrimaryPart
		Weld.Part0 = root
		Weld.Part1 = Para.PrimaryPart
		local WeldingCfr = root.CFrame --This is the world cframe where you want the bullet to be welded to
		local ObjectCframe = root.CFrame:ToObjectSpace(WeldingCfr):Inverse()
		Weld.C1 = ObjectCframe * CFrame.Angles(0,math.rad(180),0)
		animtrack:Play()
		root.AssemblyLinearVelocity = root.AssemblyLinearVelocity / 10
		print("Parachuting!")
		deploynoise:Play()
		chuting = true
		wait(0.5)
		root.AssemblyLinearVelocity = root.AssemblyLinearVelocity / 5
		if chuting == true then
			animtrack2:Play()
		end
		while chuting == true do
			wait(0.01)
			root.AssemblyLinearVelocity = root.CFrame.LookVector * 30 + Vector3.new(0,-50,0)
		end
		
		if chuting == false then
			Weld:Destroy()
			Para.Union.FlyWeld:Destroy()
			Para.Union.AssemblyLinearVelocity = root.CFrame.LookVector * -30
		end
	end
end)

humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
	if humanoid.FloorMaterial ~= Enum.Material.Air then
		animtrack:Stop()
		animtrack2:Stop()
		if chuting == true then
			landingsound:Play()
		end
		paraready = false
		chuting = false
	end
end)

humanoid.Touched:Connect(function(hit)
	if humanoid.FloorMaterial == Enum.Material.Air and hit.Transparency ~= 1 then
		animtrack:Stop()
		animtrack2:Stop()
		if chuting == true then
			landingsound:Play()
		end
		paraready = false
		chuting = false
	end
end)

character.Humanoid.Died:Connect(function()
	animtrack:Stop()
	animtrack2:Stop()
	paraready = false
	chuting = false
	alive = false
end)

UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if input.KeyCode == Enum.KeyCode.C then
		animtrack:Stop()
		animtrack2:Stop()
		if chuting == true then
			landingsound:Play()
		end
		paraready = false
		chuting = false
	end
end)

and this is my Rope Swing code


UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if input.KeyCode == Enum.KeyCode.Space and canSwing() then
		local nearbyPart = getNearestPart()
		if nearbyPart then
			animtrack:Play()
			wait(0.1)
			connectRope(nearbyPart)
			if swinging then
				wait(0.8)
				breakRope()
				animtrack:Stop()
				wait(0.01)
				root.AssemblyLinearVelocity = camera.CFrame.LookVector * 110 + Vector3.new(0,50,0)
			end
		end
	end
end)

UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if input.KeyCode == Enum.KeyCode.Space and swinging then
		breakRope()
		animtrack:Stop()
		wait(0.01)
		root.AssemblyLinearVelocity = camera.CFrame.LookVector * 110 + Vector3.new(0,50,0)
	elseif input.KeyCode == Enum.KeyCode.C and swinging then
		breakRope()
		animtrack:Stop()
	end
end)

while true do
	wait(0.01)
	if swinging then
		root.AssemblyLinearVelocity = root.AssemblyLinearVelocity * 1.08
	end
end	

obviously some parts are missing, im just making it harder for lazy people to steal my code, but i left everything important that could be useful to anyone trying to help me. if anyone could help me, i would appreciate it very much!

You could try making 2 BoolValues, one that represents if it is currently swinging and the other representing if it is currently parachuting. When the user starts parachuting, first check that the swinging bool is false, then set the parachuting bool to true. Likewise, when the user starts swinging, check that the parachuting bool is false, then set the swinging bool to true.
Ensure that you set the bool back to false when the user stops parachuting / swinging.

1 Like

since these scripts are separate and they both are checks based off if the player presses space while in the air, it would be impossible to have one bool value the only one that triggers, considering the fact that they are both triggered by the same action. however, i did actually do a semi-fix myself by just making it so if you press space and it hasnt been half a second of falling, then it disables the parachute in the parachute code so both wont be able to happen at once, the only problem is, is that if you fall for half a second and then ropeswing, which is less likely but still may happen, then you will still activate both at the same time

i still do want a different solution though, this is only a temporary fix so i can actually test ropeswinging while im developing my game

apologies for necro-bumping, but a solution could be just to use a global environment variable and define parachuting and rope swinging by separate booleans

such as
_G.parachute
and
_G.rope_swinging.

I’ve heard there’s some reasons to avoid using _G, but those might not be relevant in your situation.