Hey there! I'm making a script where you can dash to the enemy your mouse is pointing at. I keep on getting an error.
Script (Local):
--[[ Values ]]--
local canDash = true
--[[ Math ]]--
--[[ Services ]]--
local runService = game:GetService("RunService")
local userInputService = game:GetService("UserInputService")
--[[ Player Variables ]]--
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local mouse = player:GetMouse()
--[[ Variables ]]--
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
--[[ Functions ]]--
--[[ Script ]]--
runService.RenderStepped:Connect(function()
local mTarget = mouse.Target
local humanoid = mTarget.Parent:FindFirstChild("Humanoid")
local targetHumanoidRootPart = mTarget.Parent:FindFirstChild("HumanoidRootPart")
if not targetHumanoidRootPart then return end
local distance = (targetHumanoidRootPart.Position - humanoidRootPart.Position).Magnitude
if mTarget.Parent.Name == player.Name then return end
if humanoid then
userInputService.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.E then
local humanoid = mTarget.Parent:FindFirstChild("Humanoid")
if canDash == true and humanoid.Health > 0 and humanoid and not distance > 40 then
canDash = false
humanoidRootPart.CFrame = targetHumanoidRootPart.CFrame
wait(.3)
canDash = true
end
end
end)
end
end)
Full Error:
17:24:15.855 Players.ColdFoxy07.Backpack.Katana.Dash:38: attempt to compare number and boolean - Client - Dash:38
I know the script is probably not very efficient, but I tried my best ^-^. Thanks for reading!

2 comments
uh whic part is it xd. what if you make and distance < 40 instead of not distance > 40
The error is on line 38, and changing distance to < instead of > did not work either.