#When i press q to dash to the left, it works. But when i dash to the right it doesnt work

31 messages · Page 1 of 1 (latest)

flint phoenix
#

-- getting services

local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local char = script.Parent -- in our character
local humanoid = char:WaitForChild("HumanoidRootPart")
local debounce = false -- cd

-- getting keys

local aKey = false
local dKey = false

mouse.KeyDown:Connect(function(key)
if key == "a" then
aKey = true
elseif key == "d" then
dKey = false
end
end)
mouse.KeyUp:Connect(function(key)
if key == "a" then
aKey = true

elseif key == "d" then
    dKey = false
    
end

end)

UIS.InputBegan:Connect(function(key, gpe)
if gpe then return end
if key.KeyCode == Enum.KeyCode.Q then
if aKey == true then
if debounce == false then
local velocity = Instance.new("BodyVelocity", humanoid)
velocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
velocity.Velocity = humanoid.CFrame.RightVector*-100
game.Debris:AddItem(velocity, 0.2)
print("dashleft")
debounce = true
wait(1)
debounce = false
end
elseif dKey == true then
if debounce == false then
local velocity = Instance.new("BodyVelocity", humanoid)
velocity.MaxForce = Vector3.new(math.huge,0,math.huge)
velocity.Velocity = humanoid.CFrame.RightVector*100
game.Debris:AddItem(velocity, 0.2)
print("dashRight")
debounce = true
wait(1)
debounce = false
end
end
end
end)

lethal wraith
#

Your mouse key thingy is so weird

lethal wraith
flint phoenix
#

it's js the elseif dkey line that's not workingh

ashen anchor
#

Why are you using mouse.Keydown?

#

And bodyvelocity is deprecated

#

Can you add prints to debug

flint phoenix
ashen anchor
#

I’ve never used mouse.Keydown

#

Does it actually just return a string of any key pressed?

bright rapids
ashen anchor
#

I’ll look in to it

flint phoenix
#

oh

ashen anchor
flint phoenix
ashen anchor
#

Yeah

#

Wherever you put the prints, which ones printed

flint phoenix
#

first part i'm doing left and then it prints

ashen anchor
#

hmm

#

oh

#

you are setting dkey to false here

flint phoenix
#

let me check that

clever coral
#

damn that dash is quite fast

flint phoenix
#

solved

dire sparrowBOT
#

studio** You are now Level 4! **studio

flint phoenix
#

thank you all for helping me

ashen anchor
#

np

#

good luck