Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

attack that starts with a left punch and when the punch key is pressed again it is a right punch?

I have made a punching animation that has a left and a right punch but how do i make it so that after the left punch is played the right punch is next?

7 comments

0

What script do you have?

0

the problem is i dont know how to script it

0

you just make another animation that has a left punch and another that is just a right punch i guess

0

but how would i tell the script to switch to that animation?

0

using math.random may work.

0

This question makes absolutely no sense at all. It is a lot easier to assign the two punches to different keys (it would also be easy for the two keys to be directly next to each other).

0

You should give UserInputService a shot. The UIS tutorial has sample code that you can implement to your game

2 answers

✓ Accepted answer

if the value is true then the player will do a right punch if the value is false then the player will left punch

Where it says print("Player Has Left/Right Punched!") add the animation script under it!

local plr = game.Players.LocalPlayer
local folder = Instance.new("Folder")
local tf = Instance.new("BoolValue")

wait()

folder.Parent = plr.Character
folder.Name = "DataStored"

wait()

tf.Parent = plr.Character.DataStored
tf.Name = "PunchStat"

wait()

if plr.Character.DataStored.PunchStat.Value == false then

print("Player Has Left Punched!")

elseif plr.Character.DataStored.PunchStat.Value == true then

print("Player Has Right Punched!")

end

You can simply just make a bool (true-false) value and toggle it. Then use a conditional statement (if-then) to check if it’s true or not and play the animations based on it.

Here’s a rough example :

local bool = false

bool = not bool --"Toggles" the bool value (if bool is true, it turns to false, or vice versa)

if bool == true then -- The "== true" isn’t necessary for checking true things, but I just prefer having it
    print('true!') -- Left punch animation goes here
else
    print('false!') -- Right punch animation goes here
end

You can use this example to make your punch animations play after the other.

Hope this helped!

This discussion is preserved as it was. New answers, comments, and votes are closed.