So, I want so that when the player presses "q" they punch and cause damage to other players.
so we've got a problem hueston????? Punch Script?
2 answers
Hate to break it to you, Mr. Lovell, but ScriptingHelpers is not a request site. This script could get very complex as well, most people wouldn't just hand you a script like this. To comply with the Community Guidelines next time, show us that you've done some researched and atleast tried to do it. Here's an article to help you make a better question next time.. Sorry about that!
As SchonXIV previously said, ScriptingHelpers is not a request site. However, we can give you some tips on how to complete said problem.
The Humanoid has properties that allow players to take damage.
An example of how to take damage to a player would be to run the following code on a server script with filtering enabled:
-- Define variables
local player = game.Players.PLAYERNAMEHERE
local hitDamage = 2
-- Take damage from the player
player.Character.Humanoid:TakeDamage(hitDamage)
The code will request the humanoid and will run the function :TakeDamage(). You should make sure that the Character does exist in the game so that the function won't error.
Regarding you pressing the letter 'q' to punch, ROBLOX has many services that will allow you to do this. The code below will allow you to run your code when the letter 'q' is pressed on the keyboard.
function onKeyPress(actionName, userInputState, inputObject)
if userInputState == Enum.UserInputState.Begin then
-- Play animation
-- Get who they are punching (onTouched events, raycasts etc, so many ways)
-- Take damage from humanoid
end
end
game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.Q)
The above code was taken straight out of the wiki, the wiki is a useful source to research this information. I suggest you check it out here.
Again, apologies we cannot just make the script for you. There are many other ways to also learn how to make this punching system. There will be many free models but keep in mind of the 'viruses' hidden within them.
Hope this helped! :)
1 comment
This makes me look like a jerk. Thanks, lol.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
"Mr. Lovell" Boi