Pls help me find out why this script doesn't work

local DASH_DISTANCE = 20
local DASH_SPEED = 100
local DASH_SLOWDOWN = 5

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild(“Humanoid”)

local isDashing = false

local function onDash()
if isDashing then
return
end

isDashing = true
local currentVelocity = character.HumanoidRootPart.Velocity

character.HumanoidRootPart.Velocity = character.HumanoidRootPart.CFrame.lookVector * DASH_SPEED

local stopEvent
stopEvent = character.HumanoidRootPart.AncestryChanged:Connect(function(_, parent)
	if parent == nil then -- Check if the character is removed from the game
		stopEvent:Disconnect()
		return
	end
	if not isDashing then
		return
	end

	local currentSpeed = character.HumanoidRootPart.Velocity.magnitude
	character.HumanoidRootPart.Velocity = character.HumanoidRootPart.Velocity * (1 - DASH_SLOWDOWN)
	if currentSpeed < 1 then
		isDashing = false
	end
end)

wait(2) 
isDashing = false
script.Parent.MouseButton1Click:Connect(function(onDash)

end)
end

The script does not work when the button is clicked

1 Like

What exactly is the issue? Giving just code and nothing else can be confusing and make it a lot harder to find the issues with it.

1 Like

“Doesn’t work” is not enough information to fix a script. If there is an error, list the error with the line number it happens on. Also give us the desired behavior, and the actual behavior of the script.

3 Likes

When pressing the button, the player should do a somersault, but this does not happen. The problem is most likely in the line: ```
script.Parent.MouseButton1Click:Connect(function(onDash)

1 Like