When I use a KeyDown event and I test it, it works sometimes but sometimes it doesn't and I'll have to spam the key and it might work.Also, I'm using a localsript.Here's an example of a code:
wait(3)
Player = game.Players.LocalPlayer
Char = Player.Character
debounce = false
duh = 0
mouse = Player:GetMouse()
spe = Char.Humanoid.WalkSpeed
function OnDown(key)
if debounce == true then return end
debounce = true
local Key = key:lower()
if Key == "q" then
x = Instance.new("Part")
local SlashSound = Instance.new("Sound")
SlashSound.SoundId = "http://www.roblox.com/asset/?id=236382703"
SlashSound.Parent = x
SlashSound.Volume = .7
SlashSound:play()
x.Shape = "Block"
x.CanCollide = false
x.Anchored = true
x.TopSurface = "Smooth"
x.BottomSurface = "Smooth"
x.Parent = Workspace
x.Size = Vector3.new(100, 9, 100)
x.BrickColor = BrickColor.new("Bright violet")
x.Name = "Poison"
m = Instance.new("SpecialMesh", x)
m.MeshType = "FileMesh"
m.MeshId = "http://www.roblox.com/asset/?id=1095708"
m.Scale = Vector3.new(100, 100, 150)
x.CFrame = Player.Character.Torso.CFrame*CFrame.new(0, 0, 0)
x.Touched:connect(function(Part)
if Part.Parent:FindFirstChild("Humanoid") ~= nil and Part.Parent:FindFirstChild("Humanoid") ~= Player.Character.Humanoid and Part.Parent.Name ~= "Wall" then
if duh == 0 then
duh = 1
Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health-25
wait(0.01)
duh = 0
end
end
end)
wait(50)
debounce = false
end
end
mouse.KeyDown:connect(OnDown)

2 comments
Thanks.
You're welcome !