How to make a dashing script using a value?

I know how to do all the animations, UIS, and values but how to make a dash using a boolValue? (I decided to put a boolValue in StarterCharacterScripts to know if the Character “isDashing” or not)

I don’t know if this is gonna work and help but
Create a local script in the StarterCharacterScripts and name it DashScript

--Plr
local plr = game:GetService("Players").LocalPlayer

local dashkey = Enum.KeyCode.LeftShift
local UIS = game:GetService("UserInputService")
local isDashing = script.Parent:WaitForChild("isDashing")
local root = script.Parent:WaitForChild("HumanoidRootPart")
local deb = game:GetService("Debris")

--Dash Event
local cooldown = false
UIS.InputBegan:Connect(function(inp,gmp)
	if gmp then
		return
	end
	if inp.KeyCode == dashkey and not cooldown then
		isDashing.Value = true
		cooldown = true
		
		local newAttact = Instance.new('Attachment',root)
		local i = Instance.new('VectorForce')
		i.Attachment0 = newAttact
		i.Force = Vector3.new(0,0,-30000) -- Speed
		i.Parent = root
		i.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
		deb:AddItem(i,.05)
		deb:AddItem(newAttact,.05)
		task.wait(1)-- cooldown time
		isDashing.Value = false
		cooldown = false
	end
end)

This script is assuming you want left shift to run for PC and a button hold to run for mobile. Add in a local script into StarterPlayerScripts. Add an animation into the new local script and name it “Dash” after entering your dash animation ID into its properties. Also name the bool value in StarterCharacterScripts “Dash” and then paste the script below into the new local script. Also revise all the commented areas to suit your game and you will have a working dash system for mobile and PC.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local UIS = game:GetService("UserInputService")
local MobileRun = player.PlayerGui:WaitForChild('ScreenGui').TextButton -- Or your mobile dash button (Must be a text button or image button)

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		player.Character.Dashing.Value = true
		player.Character.Humanoid.WalkSpeed = 32 -- Or your desired run speed
		local Humanoid = player.Character.Humanoid
		local DashAnim = script:WaitForChild("Dash")
		local DashAnimTrack = Humanoid.Animator:LoadAnimation(DashAnim)
		DashAnimTrack:Play()
	end
end)

UIS.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		player.Character.Dashing.Value = false
		player.Character.Humanoid.WalkSpeed = 16 -- Or your desired walk speed
		local Humanoid = player.Character.Humanoid
		local DashAnim = script:WaitForChild("Dash")
		local DashAnimTrack = Humanoid.Animator:LoadAnimation(DashAnim)
		DashAnimTrack:Stop()
	end
end)

MobileRun.MouseButton1Down:Connect(function()
	player.Character.Dashing.Value = true
	player.Character.Humanoid.WalkSpeed = 32 -- Or your desired run speed
	local Humanoid = player.Character.Humanoid
	local DashAnim = script:WaitForChild("Dash")
	local DashAnimTrack = Humanoid.Animator:LoadAnimation(DashAnim)
	DashAnimTrack:Play()
end)

MobileRun.MouseButton1Up:Connect(function()
	player.Character.Dashing.Value = false
	player.Character.Humanoid.WalkSpeed = 16 -- Or your desired walk speed
	local Humanoid = player.Character.Humanoid
	local DashAnim = script:WaitForChild("Dash")
	local DashAnimTrack = Humanoid.Animator:LoadAnimation(DashAnim)
	DashAnimTrack:Stop()
end)