Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Does a keydown need a debounce with it?

Asked by 7 years ago
Edited 7 years ago

local User = game.Players.LocalPlayer.Character local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse()

local function MercuryLightningMeteorAttack(key) key = key:lower() if key == "q" then local Meteor = Instance.new("Part",workspace) Meteor.Shape = 0 Meteor.Material = 288 Meteor.Name = "Meteor" Meteor.Anchored = true Meteor.Size = Vector3.new(6.33,6.33,6.33)

local MercuryLightning = Instance.new("ParticleEmitter",Meteor)
MercuryLightning.Texture = "rbxassetid://567502351"
MercuryLightning.Size = NumberSequence.new(10)
MercuryLightning.Name = "MercuryLightning"
MercuryLightning.Lifetime = NumberRange.new(0.7)
MercuryLightning.Rate = 20
MercuryLightning.Rotation = NumberRange.new(1)
MercuryLightning.RotSpeed = NumberRange.new(50)

local MercuryLightningAura = Instance.new("ParticleEmitter",Meteor)
MercuryLightningAura.Texture = ""

local MercuryLightningMeteorAttackSpeed = Instance.new("BodyVelocity",Meteor)
MercuryLightningMeteorAttackSpeed.MaxForce = Vector3(math.huge,math.huge,math.huge)
MercuryLightningMeteorAttackSpeed.Velocity = User.Torso.CFrame.LookVector*80
end

MercuryLightningMeteorAttack()


Lately, I been trying to make a keydown that will summon a lightning ball from my body but the keydown is causing the whole problem here why isn't it working?

0
Hey just a heads up, not all of the script was inside the code break, could you edit it all in for us? ( = Also Sometimes its a good idea to have a debounce just to keep you safe in the long run but most of the time, no you would HAVE to have one. Stephenthefox 94 — 7y
0
It's very hard to read because its not all in the Code Block format. Debounce is only used if it does the action that is triggered by the event multiple times, so unless it is making a bunch of lightning if you press it once, I don't think debounce is your issue. Tempestatem 884 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Might I recommend some orderly adjustments:

*Also, you don't need to use Debounce, keys are made to press over and over- however.. If it was a .Touched or .Changed or anything that can loop infinitely, it would be needed. *

An example of Debounce can be as simple as:

-- || Variables ||
local Part = Instance.new("Part", game.Workspace") Part.Position = Vector3.new(0,15,0) -- So it doesn't fall through the potential baseplate I'm assuming you have.
local Debounce = false

-- || Touch Function ||
Part.Touched:connect(function(Hit)
if Hit.Parent:FindFirstChildOfClass("Humanoid") and not Debounce then
Debounce = true
print(Hit.Parent.." has hit Part!")
wait(2)
Debounce = false
end
end)

Additionally: Look up UserInputService, it'll be more ideal for what you're doing, .GetMouse() is considered Depicted EDIT: For Keyboard Actions..

Switch around User = game.Players.LocalPlayer.Character and Player = game.Players.LocalPlayer It'll save you some typing... And won't confuse us as much...

LASTLY: You need to adjust your Code Block, some of your code is illegible.

Ad

Answer this question