Is there a way to test if a key is down in an if then statement? I tried to substitute the if then statement with a function, but the wait(.1) didn't work. I am trying to set off and explosion if the space bar has been help down after a jump. Any Ideas? this is a local script in StarterPlayerScripts.
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local debounce = 0
humanoid.Jumping:connect(function(key)
wait(.1)
mouse.KeyDown:connect(function(key)
if key:lower() == " " then
if debounce == 0 then
debounce = 1
if not character:FindFirstChildOfClass("ForceField") then
local ForceField = Instance.new("ForceField", character)
ForceField.Visible = false
end
wait(0.2)
local Explosion = Instance.new("Explosion", character)
Explosion.Position = character.HumanoidRootPart.Position
Explosion.Visible = false
debounce = 0
end
end
end)
end)

2 comments
no
Helpful..