Here is the download to the game: https://mega.nz/fm/Ua4EGBDZ When you press Q, you are meant to punch. It works in studio, but not in roblox player. It's an FE enabled game with r15 characters. It only gives one error in roblox player; "Infinite yield possible on ServerScriptService("Punch")", something like that, but you can see yourself.
COMMUNITY QUESTION
How do I make animations work when I press Q in ROBLOX player?
1 answer
Well to start you need a local script. in this local script you will be able to press Q to punch, it will play the animation, and fire tuple arguments to the server to see if it should punch
The local script should be in StarterCharacterScripts, and should look something like this:
local UIS = game:GetService('UserInputService')
local RS = game:GetService('ReplicatedStorage')
local PunchEvent = RS:WaitForChild('PunchEvent')
local Punching = false
local Damaging = false
local Char = script.Parent
local Humanoid = Char.Humanoid
local RightHand = Char:WaitForChild('RightHand')
local PunchAnimation = Instance.new('Animation') -- define the animation instance, or make an animation instance
PunchAnimation.AnimationId = 'rbxassetid://67584958' -- if you have a new instance animation, make sure to set the right id
local Damage = 20 -- put damage here
UIS.InputBegan:connect(function(input)
if input.KeyCode = Enum.KeyCode.Q then
if not Punching then
Punching = true
Damaging = true
local PunchTrack = Humanoid:LoadAnimation(PunchAnimation)
PunchTrack:Play()
PunchTrack.Stopped:wait()
Punching = false
Damaging = false
end
end
end)
RightHand.Touched:connect(function(hit)
if hit.Parent:FindFirstChildOfClass('Humanoid') and Punching and Damaging then
Damaging = false
PunchEvent:FireServer(hit.Parent:FindFirstChildOfClass('Humanoid'), Damage)
end
end)
now there should be an event in ReplicatedStorage and a server script in ServerScriptService. in this script should be something like this:
local PunchEvent = game:GetService('ReplicatedStorage'):WaitForChild('PunchEvent')
PunchEvent.OnServerEvent:connect(function(client, HumanoidToDamage, Damage)
HumanoidToDamage:TakeDamage(Damage)
end)
this should allow for the animation to play, and the damage to be done
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Why doesn't my game work?
What do you mean?
I posted a link to the download of my game, it works in studio, but not in in-game.