I am working on an anime combat game and I have come across an issue I can’t seem to fix.
For determining punches, I detect the punch on the client and send information to the server.
Whenever I receive the info on the server, I set the player’s jumppower to 0 so they can’t jump while they are punching.
Following this, at the end of the script, I do a spawn function and a task.wait() which resets the jumppower back to normal after .5 seconds. While if you punch once it works, but if you punch multiple times into a combo, it does not work as it may set the jumppower to 0 at every punch, but .5 seconds later it resets, so it could reset in the middle of the punch, which breaks the whole effect I am trying to achieve here.
Create a value or a variable to let the scripts know if you’re still doing a combo. For example if I swing once, make a value true until you stop attacking or if you reach the end of the combo. Then simply apply some if then statements.
I understand what you are saying, but do you mind clarifying this?
If I create a value telling the script not to have jumppower for player, would I destroy it maybe 0.1 seconds after the animation has finished? If so, if multiple strikes are done, that would make multiple values created? Or would I use one base value as in a bool value or something to determine this?
local PunchAnimations = {
Punch1,
Punch2,
Punch3,
Punch4,
Punch5,
}
AnimToPlay = 1
local Attacking = false
RemoteEvent.OnServerEvent:Connect(function(plr)
---Add basic checks here
------------------------
--Set jumppower or whatever here
local CurrentPunchAnim = PunchAnimations[AnimToPlay]
CurrentPunchAnim:Play()
Attacking = true
CurrentPunchAnim.Stopped:Connect(function()
Attacking = false
--Change their jump power back
end)
AnimToPlay += 1
local CurrentCheck = AnimToPlay
task.delay(2,function() --Waits 2 seconds
if AnimToPlay == CurrentCheck then
Attacking = false
--End the combo and set jump power back
end
end)
end)
Ah I see. But if we are resetting their jump power when the anim has stopped, what point is there in the task delay function? When the anim stops, the jump power resets.
local PunchAnimations = {
Punch1,
Punch2,
Punch3,
Punch4,
Punch5,
}
AnimToPlay = 1
local Attacking = false
RemoteEvent.OnServerEvent:Connect(function(plr)
---Add basic checks here
------------------------
--Set jumppower or whatever here
local CurrentPunchAnim = PunchAnimations[AnimToPlay]
CurrentPunchAnim:Play()
Attacking = true
CurrentPunchAnim.Stopped:Connect(function()
if AnimToPlay >= 5 then
Attacking = false
--Change their jump power back
else
local CurrentCheck = AnimToPlay
task.delay(2,function() --Waits 2 seconds
if AnimToPlay == CurrentCheck then
Attacking = false
--End the combo and set jump power back
end
end)
end
end)
AnimToPlay += 1
end)