You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I am making a battlegrounds game and I added a dashing system which dashes to a different direction depending on which key you hold before pressing q. -
What is the issue? Include screenshots / videos if possible!
When pressing to keys at once, or releasing a key for a very short period of time it doesn’t work, sometimes the key press doesn’t even register. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried several different mechanics and searched over the devforum.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local script in starter character scripts
local UserInputService = game:GetService("UserInputService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local dashAnimation = workspace.DashAnimation
local dashAnimationTrack = humanoid:LoadAnimation(dashAnimation)
local canDash = true
local cooldown = 5
local keyDown = nil
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then
return
end
if not canDash then
return
end
if input.KeyCode == Enum.KeyCode.Q then
canDash = false
dashAnimationTrack:Play()
local dash = Instance.new("BodyVelocity")
dash.MaxForce = Vector3.new(1,0,1) * 30000
if keyDown == "W" then
dash.Velocity = character.HumanoidRootPart.CFrame.lookVector * 100
elseif keyDown == "S" then
dash.Velocity = character.HumanoidRootPart.CFrame.lookVector * 75 * -1
elseif keyDown == "A" then
dash.Velocity = character.HumanoidRootPart.CFrame.RightVector * 50 * -1
elseif keyDown == "D" then
dash.Velocity = character.HumanoidRootPart.CFrame.RightVector * 50
else
dash.Velocity = character.HumanoidRootPart.CFrame.lookVector * 100
end
dash.Parent = character:WaitForChild("HumanoidRootPart")
for i=1, 8 do
wait(0.1)
dash.Velocity *= 0.7
end
dashAnimationTrack:Stop()
dash:Destroy()
task.wait(cooldown)
canDash = true
elseif input.KeyCode == Enum.KeyCode.W then
keyDown = "W"
elseif input.KeyCode == Enum.KeyCode.A then
keyDown = "A"
elseif input.KeyCode == Enum.KeyCode.S then
keyDown = "S"
elseif input.KeyCode == Enum.KeyCode.D then
keyDown = "D"
end
end)
UserInputService.InputEnded:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.W then
keyDown = nil
elseif input.KeyCode == Enum.KeyCode.A then
keyDown = nil
elseif input.KeyCode == Enum.KeyCode.S then
keyDown = nil
elseif input.KeyCode == Enum.KeyCode.D then
keyDown = nil
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.