Can you help me with a disable parkour script

hello developers how has your day been so far, anyway i need your help with something in my new game.

so in my game i have a double jump script and i was hope you guys knew a way to disable it when you join the sword fight arena

here is the code can you help me?

-- -- put in starter character scripts

local MAX_JUMPS = 2;
local MAX_DIVES = 1;
local TIME_BETWEEN_JUMPS = 0.1;

local hrp = script.Parent:WaitForChild("HumanoidRootPart");
local head = script.Parent:WaitForChild("Head");
local humanoid = script.Parent:WaitForChild("Humanoid");
local particle = script:WaitForChild("Particle");
particle.Parent = nil;

local anim;
if (humanoid.RigType == Enum.HumanoidRigType.R15) then
	anim = humanoid:LoadAnimation(script:WaitForChild("Roll_R15"));
else
	anim = humanoid:LoadAnimation(script:WaitForChild("Roll_R6"));
end

local canJump = true;
local jumpCount = 0;

local canDive = true;
local diveCount = 0;
local totalDives = 0;

local function createParticle(cf, t)
	local part = Instance.new("Part");
	part.Size = Vector3.new(4, 4, 4)
	part.Anchored = true;
	part.CanCollide = false;
	part.Transparency = 1;
	part.CFrame = cf;
	part.Parent = game.Workspace;
	
	local clone = particle:Clone();
	clone.Enabled = true;
	clone.Parent = part;
	
	local life = clone.Lifetime;
	for i = 0, 1.1, 0.1 do
		clone.Lifetime = NumberRange.new((1-i)*life.Min, (1-i)*life.Max + 0.1);
		wait(t*0.1);
	end

	game:GetService("Debris"):AddItem(part, t);
end

local function onStateChange(old, new)
	if (new == Enum.HumanoidStateType.Landed or new == Enum.HumanoidStateType.Swimming or new == Enum.HumanoidStateType.Running or new == Enum.HumanoidStateType.RunningNoPhysics) then	
		canDive = true;
		canJump = true;
		jumpCount = 0;
		diveCount = 0;
		anim:Stop();
	elseif (new == Enum.HumanoidStateType.Freefall or new == Enum.HumanoidStateType.Flying) then
		wait(TIME_BETWEEN_JUMPS)
		canJump = true;
		canDive = true;
	end
end

local function onJumpRequest()
	if (not humanoid or humanoid:GetState() == Enum.HumanoidStateType.Dead) then
		return;
	end
	
	if (canJump and jumpCount < MAX_JUMPS) then
		canJump = false;
		jumpCount = jumpCount + 1;
		humanoid:ChangeState(Enum.HumanoidStateType.Jumping);
		
		if (jumpCount > 1) then
			if (jumpCount % 2 == 0 or humanoid:GetState() == Enum.HumanoidStateType.Flying) then
				anim:Play(nil, nil, 2.5);
			end
			local z = hrp.CFrame:vectorToObjectSpace(hrp.Velocity).z;
			createParticle(hrp.CFrame * CFrame.new(0, -1, 0), .3);
		end
	end
end

local function onInput(input, process)
	if (process or not humanoid or humanoid:GetState() == Enum.HumanoidStateType.Dead) then
		return;
	end	
	
	if (input.KeyCode == Enum.KeyCode.LeftShift or Enum.KeyCode.LeftControl and humanoid:GetState() == Enum.HumanoidStateType.Freefall and canDive and diveCount < MAX_DIVES) then
		canDive = false;
		diveCount = diveCount + 1;
		totalDives = totalDives + 1;
		
		anim:Stop();
		humanoid:ChangeState(Enum.HumanoidStateType.Flying);
		hrp.Velocity = hrp.CFrame:vectorToWorldSpace(Vector3.new(0, humanoid.JumpPower, -humanoid.WalkSpeed*3));
		hrp.RotVelocity = hrp.CFrame:vectorToWorldSpace(Vector3.new(-math.rad(135), 0, 0));
		createParticle(hrp.CFrame * CFrame.new(0, -1, -3), .3);
		

		local currentDive = totalDives;
		wait(0.5);
		if (currentDive == totalDives) then
			hrp.RotVelocity = hrp.CFrame:vectorToWorldSpace(Vector3.new(0, 0, 0));
		end
	end
end

local function onTouched(touchingPart, humanoidPart)
	if (humanoid:GetState() == Enum.HumanoidStateType.Flying and touchingPart.CanCollide) then
		local ray = Ray.new(humanoidPart.Position, -humanoidPart.Velocity * 10);
		local hit, pos, normal, material = game.Workspace:FindPartOnRayWithWhitelist(ray, {touchingPart});
	
		if (material ~= Enum.Material.Water and material ~= Enum.Material.Air and normal:Dot(Vector3.new(0, 1, 0)) <= 0.5) then
			hrp.Velocity = (normal + Vector3.new(0, 1, 0)) * 30;
			anim:Play(nil, nil, 2.5);
		end
		
		humanoid:ChangeState(Enum.HumanoidStateType.Freefall);
	end
end

if (MAX_DIVES > 0) then
	humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false);
	humanoid.Touched:Connect(onTouched);
	game:GetService("UserInputService").InputBegan:Connect(onInput);
end

humanoid.StateChanged:Connect(onStateChange);
game:GetService("UserInputService").JumpRequest:Connect(onJumpRequest)

hope to hear from you soon
–teyougin

just make it disable when it Tp’s you to arena!??

i don’t know how to do that. :sad: :sad: :sad: :sad:

When the player is double jumping in the if statement that checks if the players jumped for a double jump include a second condition which checks if the player is NOT in the sword fight arena

how do i do that i am very very bad at scripting

You can make a bool value and set it to false or true depending on whether or not they are in the arena and check for that same bool variable to be false

can you show me the code for that so i can add it to the script please. :pray: :pray: :pray: :pray:

Just add [script location here].Disabled = true when player tp’s to arena. You can ask if u dont understand

okay thank you i will try this when i work on the game this weekend, thank you for all your help.

if you want i will give you admin commands as a thank you for your help. it’s up to you. :slight_smile:

1 Like