Basically, I made a fireball that shoots when I press the letter f. But I want to make it so if I hold down f, the fireball will get larger and then I can release to fire it off. How do I do this?
✓ ANSWER ACCEPTED
How do you make it so if you hold down the button, a blast gets larger and does more damage??
2 answers
✓ Accepted answer
Hi Tim,
What you're trying to accomplish is simple and the answer previous to this by chexy doesn't answer your question.You want the blast to keep growing when you keep holding down the key, and you need to use booleans for that. You make a boolean true upon clicking, and make it false upon ending the click. And while the boolean is true, you need to run a function that increases the size. Here, I'll just show you how to do it using UserInputService.
local uis = game:GetService("UserInputService");
local players = game:GetService("Players");
local player = players.LocalPlayer;
local holding_down = false;
uis.InputBegan:Connect(function(obj, gp)
if obj.KeyCode == Enum.KeyCode.Q and not gp then
holding_down = true;
local part; -- Define the part somehow and I'm going to assume this part's had it's appropriate properties set.
while holding_down and wait() do
part.Size = part.Size + Vector3.new(.1, .1, .1); -- Adds this to the size while the key is being held.
end
end
end)
uis.InputEnded:Connect(function(obj, gp)
if obj.KeyCode == Enum.KeyCode.Q and not gp then
holding_down = false;
end
end)
##Well, I hope I helped and have a wonderful day/night.
Thanks,
Best regards,
~~ KingLoneCat
You can use UserInputService or ContextActionService for keybinding. Here's to start you off; This is a LocalScript:
local uis = game:GetService('UserInputService')
uis.InputBegan:Connect(function(key, gpe)
-- When a key is pressed, this event is fired
if key.KeyCode == Enum.KeyCode.F then --A check to see if the player pressed the 'F' key
-- increase dmg and size of fireball
end
end)
uis.InputEnded:Connect(function(key, gpe) then
-- If a player has let go of a key, this event is fired.
if key.KeyCode == Enum.KeyCode.F then --A check to see if the 'F' key was let go of
-- Release the fireball and deal some damage to the player it hit, if it has
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

15 comments
how did you make text so big?
I had an issue, you put " local players = players:GetService("Players"); " But it's an error, it says " attempt to index global 'players' (a nil value)" You can't use players when your defining players I think
Lol, let me update.
There, it should work now.
Black, you use '#' Doing ## at the beginning of the line makes it big. # is the biggest, ## is the next biggest, ### is the next biggest, and #### is an italicized different font style text. Test them out.
The script doesn't work.
Make sure it's a local script on the client.
It is a local script.
Did you define the part and set the part's properties?
Yes I did.
This is what I put to define it: local part = Instance.new("Part"); part.Size = Vector3.new(5,5,5) part.BrickColor = BrickColor.new(255,0,0) part.CFrame = player.Character.UpperTorso.CFrame part.CanCollide = true
Did you parent the part to workspace?
Also, BrickColor isn't a BrickColor3 value. So, you don't use 3 values. Just look up the names for each color and you put that in BrickColor.new().
:D It works now, thanks! I hope I didn't disturb you.
No, it's fine. Lol.