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?
Hi Tim,
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)
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