to add sound use this script local sound = script.YOURSOUNDHERE:Clone() sound.Parent = hit.Parent:FindFirstChild("Humanoid") sound:Play() game.Debris:AddItem(sound,2) note:put it after the TakeDamage function also make sure to put the sound of ur choice in the script AND put the name of the sound at the script.YOURSOUNDHERE part and the game.Debris thing make the sound,2 and the number of how long the sound is now this is how to add particles: local punchParticle = game.ReplicatedStorage["PARTICLE PART NAME"].Attachment:Clone() punchParticle.Parent = hit.Parent:FindFirstChild("HumanoidRootPart") for i, v in pairs(punchParticle:GetChildren()) do if v:IsA("ParticleEmitter") then v:Emit(30) game.Debris:AddItem(punchParticle,0.4) end end if u did the sound w/ me then put it after the game.Debris:AddItem(sound,2) if u didnt do that do it after the TakeDamage function name the particle part name to the vfx ur using add a part put an atttachment in it then put the particle emitters in it then put the part into replicated storage the game.Debris:AddItem(punchParticle,0.4) so change the 0.4 to how long the particle is and I’m still waiting on that moblie support😅
So like hit.Parent is like i think whoever you hit parent so maybe like idk just check the TUTORIALS scripts again or maybe you didn’t put it after the Damage function? Like the humanoid:TakeDamage() thing
Out of all the developers making combat systems, I gotta say, this is the only developer who took his time to explain his code and doesn’t use unnecessary code or tells you to just copy his code. It took me 2 hours to learn this and I am grateful. Keep it up man thanks a lot❤
He didn't explain the code, he explained what the code did after it was executed. If you really want to learn something from this video, you have to be slightly more advanced to understand the actual functions and components of the script.
for anyone who wants to change the damage, what you want to do is, on line 35 of the hitbox script, you wanna do this: 1. go to the script(hitbox) 2. go to line 35 3. at the end of line 35 in the parathesis put (damage + "number of your choice") and test it on a dummy to see if it works You're welcome! Edit: i'd say do a higher number
@Night_YTistaken I haven't try this but try (damage - "number") and test it, idk if it'll make it 0 so try multiple numbers until it does 0. Your welcome if it works!
Thank you very much MajesticDev, I finally learned how to make a combat for my game, really, thank you very much, I've become a big fan of yours. Your channel was the only one that got me right! I love you from the heart.
local cas = game:GetService("ContextActionService") local rs = game:GetService("ReplicatedStorage")
local events = rs:WaitForChild("Events") local hitboxEvent = events:WaitForChild("Hitbox")
local plr = game.Players.LocalPlayer local character = plr.Character or plr.CharacterAdded:Wait() local hum = character:WaitForChild("Humanoid") local animator = hum:WaitForChild("Animator")
local leftPunch = animator:LoadAnimation(script:WaitForChild("LeftPunch")) local rightPunch = animator:LoadAnimation(script:WaitForChild("RightPunch"))
local currentPunch = 0 local lastPunch = 0
local debounce = false
local function punch() if debounce then return end if tick() - lastPunch > 1.5 then currentPunch = 0 end
debounce = true if currentPunch == 0 then rightPunch:Play() hitboxEvent:FireServer(Vector3.new(3,3,3), Vector3.new(2), 10, 0.3) task.wait(0.4) debounce = false elseif currentPunch == 1 then leftPunch:Play() hitboxEvent:FireServer(Vector3.new(3,3,3), Vector3.new(2), 10, 0.3) task.wait(0.4) debounce = false elseif currentPunch == 2 then rightPunch:Play() hitboxEvent:FireServer(Vector3.new(3,3,3), Vector3.new(2), 10, 0.3) task.wait(0.8) debounce = false end if currentPunch == 2 then currentPunch = 0 else currentPunch += 1 end lastPunch = tick() end
-- SERVER SCRIPT ------------------------------------------------------------------
local rs = game:GetService("ReplicatedStorage")
local events = rs:WaitForChild("Events") local hitboxEvent = events:WaitForChild("Hitbox")
function newHitbox(character, size, offset, damage, linger) local hrp = character:FindFirstChild("HumanoidRootPart") if hrp == nil then return end local weld = Instance.new("WeldConstraint", hrp) local hitbox = Instance.new("Part") weld.Part0 = hrp weld.Part1 = hitbox
hitbox.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") == nil then return end
for _, v in pairs(hitbox:GetChildren()) do if v:IsA("ObjectValue") then if v.Value == hit.Parent then return end end end
local hitCounter = Instance.new("ObjectValue", hitbox) hitCounter.Value = hit.Parent
hit.Parent.Humanoid:TakeDamage(damage) end)
game.Debris:AddItem(hitbox, linger) end
hitboxEvent.OnServerEvent:Connect(function(plr, size, offset, damage, linger) newHitbox(plr.Character, size, offset, damage, linger) end) Edit: Also yes, I stole it from the paste bin.
i'll use this as reference since i've been trying to make a combat system with remote events, local scripts and scripts but it always bugged, thank you for uploading this since i had no consideration for bind action before this!!!
PunchScript (Localscript): local cas = game:GetService("ContextActionService") local rs = game:GetService("ReplicatedStorage") local events = rs:WaitForChild("Events") local hitboxEvent = events:WaitForChild("Hitbox") local plr = game.Players.LocalPlayer local character = plr.Character or plr.CharacterAdded:Wait() local hum = character:WaitForChild("Humanoid") local animator = hum:WaitForChild("Animator") local leftPunch = animator:LoadAnimation(script:WaitForChild("LeftPunch")) local rightPunch = animator:LoadAnimation(script:WaitForChild("RightPunch")) local currentPunch = 0 local lastPunch = 0 local debounce = false local function punch() if debounce then return end if tick() - lastPunch> 1.5 then currentPunch = 0 end debounce = true if currentPunch == 0 then rightPunch:Play() hitboxEvent:FireServer(Vector3.new(4,4,4), Vector3.new(2), 10, 0.3) task.wait(0.4) debounce = false elseif currentPunch == 1 then leftPunch:Play() hitboxEvent:FireServer(Vector3.new(4,4,4), Vector3.new(2), 10, 0.3) task.wait(0.4) debounce = false elseif currentPunch == 2 then rightPunch:Play() hitboxEvent:FireServer(Vector3.new(4,4,4), Vector3.new(2), 10, 0.3) task.wait(0.8) debounce = false end print(currentPunch) if currentPunch == 2 then currentPunch = 0 else currentPunch += 1 end lastPunch = tick() end cas:BindAction("Punch", punch, true, Enum.UserInputType.MouseButton1) ServerScript (Normal Script): local rs = game:GetService("ReplicatedStorage") local events = rs:WaitForChild("Events") local hitboxEvent = events:WaitForChild("Hitbox") function newHitbox(character, size, offset, damage, linger) local hrp = character:FindFirstChild("HumanoidRootPart") if hrp == nil then return end local weld = Instance.new("WeldConstraint", hrp) local hitbox = Instance.new("Part") weld.Part0 = hrp weld.Part1 = hitbox
EVERYONE STRUGGELING TO MAKE THE PUNCH DO MORE DAMAGE HERE!!!::: CHANGE THE PART WHERE IT SAYS TAKADAMAGE(100) TO THE AMOUNT YOU WANT! BTW:THIS IS THE HITBOX SCRIPT local rs = game:GetService("ReplicatedStorage") local events = rs:WaitForChild("Events") local hitboxEvent = events:WaitForChild("Hitbox") function newHitbox(character, size, offset, damage, linger) local hrp = character:FindFirstChild("HumanoidRootPart") if hrp == nil then return end local weld = Instance.new("WeldConstraint", hrp) local hitbox = Instance.new("Part") weld.Part0 = hrp weld.Part1 = hitbox hitbox.Transparency = 1 hitbox.CanCollide = false hitbox.CanQuery = false hitbox.Massless = true hitbox.Size = size hitbox.CFrame = hrp.CFrame + hrp.CFrame.LookVector * offset.X + Vector3.new(0,offset.Y) hitbox.Parent = character hitbox.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") == nil then return end for _, v in pairs(hitbox:GetChildren()) do if v:IsA("ObjectValue") then if v.Value == hit.Parent then return end end end local hitCounter = Instance.new("ObjectValue", hitbox) hitCounter.Value = hit.Parent hit.Parent.Humanoid:TakeDamage(damage) hit.Parent:FindFirstChild("Humanoid"):TakeDamage(100) end) game.Debris:AddItem(hitbox, linger) end hitboxEvent.OnServerEvent:Connect(function(plr, size, offset, damage, linger) newHitbox(plr.Character, size, offset, damage, linger) end) hope this might make it even more usefull also some animation id's of anims i made: left:rbxassetid://14791654126 right:rbxassetid://14791354670
@@MajesticUC thank you! But how to do punching bag which can reset himself health after 3-5 sec after health == 0 what i need to do say pls i even did humanoid and homanoid root part in punching bag and did reset health after 3 sec but after 1 reset him health become 0 and i cant change it to 100
@@mason228x Respawn script local Copy = script.Parent:Clone() local NPC = script.Parent local Humanoid for i,v in pairs(NPC:GetChildren()) do if v:IsA('Humanoid') then Humanoid = v end end if Humanoid then Humanoid.Died:Connect(function() wait(5) Copy.Parent = NPC.Parent Copy:MakeJoints() NPC:Destroy() end) else warn('Cannot find Humanoid in Respawn Script!') end
Got stuck on scripting the animation. I used r15 instead of r6, so did that mess it up perhaps; or did I just mess up somewhere in that void of code? I also used 8 different punch animations, so did that perhaps mess the whole thing up? idk anymore
as long as you used r15 animations and an r15 rig it should work fine. If you make 8 different animations you have to create 8 different variables and also store all of the anims (with their id's) inside the script.
@@MajesticUC alright but what does offset,size and that stuff mean,like should i put 4,7,1 (width,height,depth amount of studs) in size? in offset what should i do?
Offset is a vector 3 and is the x distance and y distance the centre of the hitbox will be from the character. The size is a vector 3 and is the size of the hitbox, the damage is a number value and is just the amount of damage the hitbox deals and the linger is how long the hitbox exists for before it is destroyed. Also I put in the parameters for my hitboxes in the vid and in the pastebin
I was wondering how to make it so that when you press the combat button there will be different animations like: Punch, hook, kick, kick... repeat i think that would be cooler and i would be very thankful if you made a tutorial for that
If you want something like that then that means you would need a different animation play for each tick punch that you are on so 1 would play punch 2 would play hook and so on
How this dude feels after saying the combat system doesn't work instead of checking the bug finder and using problem solving skills to figure out the conflict
How would I go about making a sound for the game? Do I have to make it myself, does Roblox have sounds that are avalible, or can I get it from other players? Please, and Thank you.
okay update didnt work. seems like this part hitbox.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") == nil then return end
for _, v in pairs(hitbox:GetChildren()) do if v:IsA("ObjectValue") then if v.Value == hit.Parent then return end end end print("hitbox.touched v in pairs")
local hitCounter = Instance.new("ObjectValue", hitbox) hitCounter.Value = hit.Parent
4:32 i was tweaking out for an hour because the animation would have gone Right punch, left punch, right punch and right punch you need to do ''If currentPunch == 2 then currentPunch = 1''
this is the local script if your too busy to write it, but its broken. can someone maybe fix it and reply with it fixed in the comments please?? ty local cas = game:GetService("ContextActionService") local plr = game.Players.LocalPlayer local character = plr.Character or plr.CharacterAdded:Wait() local hum = character:WaitForChild("Humanoid") local animator = hum:WaitForChild("Animator") local leftPunch = animator:LoadAnimation(script:WaitForChild("LeftPunch")) local rightPunch = animator:LoadAnimation(script:WaitForChild("RightPunch")) local currentpunch = 0 local debounce = false local function punch() if debounce then return end debounce = true if currentPunch == 0 then rightPunch:Play() task.wait(0.4) debounce = false elseif currentPunch == 1 then leftPunch:Play() task.wait(0.4) debounce = false elseif currentPunch == 1 then leftPunch:Play() task.wait(0.4) debounce = false elseif currentPunch == 2 then rightPunch:Play() task.wait(0.8) debounce = false end if currentPunch == 2 then currentPunch = 0 else currentPunch += 1 end end cas:BindAction("Punch", punch, true Enum.UserInputType.MouseButton1)
i was watching this video and then i realised i dont have the patience to do all this espesially when you dont explain a lot of the stuff like how to get the moon animator or what im supposed to type in the script but you seemed to help other ppl but i might just go back to making free model games
i know the video 9 months ago but still i copied the whole punch script but it didnt work, and i have ZERO idea why all i get is the "ServerScriptService.Hitbox' :41: Expected 'end' (to close 'function' at line 40), got
how do i fix the PlayerGui.PunchScript:5: attempt to index nil with 'Character' - Server - PunchScript:5 here are my 5th code line: local character = plr.Character or plr.CharacterAdded:Wait()
I have done what you said to do up to the 4:39 mark but my animation won’t work when I left click my my mouse😢. Does anyone have any recommendations that could help me get my animation to start playing 🙏
please i hope you will answer, so in my game i have a character selection system, and i want each character to have a different punch animation, hitbox size, etc.. please help me!
i only started working on studio a couple days ago, and today i encountered a problem with this. so, when i finished typing all of that up to 4:33 i tested it and when i saved it said it was uncommitted? it didnt work either? could someone tell me whats wrong?
I have an issue where whenever I m1 the animation plays at kind of half proportions, the punch starts halfway up the body, it goes half as far, etc, does anyone know how to fix this?
i can't seem to get anything to work, i have followed every bit of code that you wrote up too 4:33 and then from there nothing will play, no animations at all. i even tried to redo all the code and that didn't work. the pastebin one isn't working either. i have done everything you said to do but nothing is showing. Any help please would be nice :)
If you have any problems, feel free to ask me about them!
do you have discord server?
Yes, I linked it in another video
Do you have a tutorial to add particles to the punches
I could make one
@@MajesticUC make it I need lol
a sick video, had exactly what I was looking for and some BANGER music!
to add sound use this script
local sound = script.YOURSOUNDHERE:Clone()
sound.Parent = hit.Parent:FindFirstChild("Humanoid")
sound:Play()
game.Debris:AddItem(sound,2)
note:put it after the TakeDamage function
also make sure to put the sound of ur choice in the script AND put the name of the sound at the script.YOURSOUNDHERE part
and the game.Debris thing make the sound,2 and the number of how long the sound is
now this is how to add particles:
local punchParticle = game.ReplicatedStorage["PARTICLE PART NAME"].Attachment:Clone()
punchParticle.Parent = hit.Parent:FindFirstChild("HumanoidRootPart")
for i, v in pairs(punchParticle:GetChildren()) do
if v:IsA("ParticleEmitter") then
v:Emit(30)
game.Debris:AddItem(punchParticle,0.4)
end
end
if u did the sound w/ me then put it after the game.Debris:AddItem(sound,2)
if u didnt do that do it after the TakeDamage function
name the particle part name to the vfx ur using
add a part put an atttachment in it then put the particle emitters in it
then put the part into replicated storage
the game.Debris:AddItem(punchParticle,0.4) so change the 0.4 to how long the particle is
and I’m still waiting on that moblie support😅
im having a error in the sound part
@@n1runRealwhat was the error?
@@TheRealTiger0 i exactly couldnt understand in the console but in the script the "hit" part in the hit.parent and stuff was underlined red
So like hit.Parent is like i think whoever you hit parent so maybe like idk just check the TUTORIALS scripts again or maybe you didn’t put it after the Damage function? Like the humanoid:TakeDamage() thing
@@TheRealTiger0 i did put it after it, do i have to remove the "end)" after the fuction?
Out of all the developers making combat systems, I gotta say, this is the only developer who took his time to explain his code and doesn’t use unnecessary code or tells you to just copy his code. It took me 2 hours to learn this and I am grateful. Keep it up man thanks a lot❤
This code isnt the greatest if im gonna be 100% honest! I might remake this combat system tutorial just cos this one isnt very secure at all!!!
He didn't explain the code, he explained what the code did after it was executed. If you really want to learn something from this video, you have to be slightly more advanced to understand the actual functions and components of the script.
Omg thanks for sharing I was looking for a dev that won’t ask to copy their code Tysm to u and the ytber (dev)
Hey man I know your trying, but this tutorial is not descriptive enough for beginners.
@@MajesticUCyeah it sucks
for anyone who wants to change the damage, what you want to do is, on line 35 of the hitbox script, you wanna do this:
1. go to the script(hitbox)
2. go to line 35
3. at the end of line 35 in the parathesis put (damage + "number of your choice")
and test it on a dummy to see if it works
You're welcome!
Edit: i'd say do a higher number
and if you don't deal any damage at all, then what?
@@Night_YTistaken
:)
@Night_YTistaken
I haven't try this but try (damage - "number") and test it, idk if it'll make it 0 so try multiple numbers until it does 0. Your welcome if it works!
@@lazermaven4870 ye sorry i forgot to say that i fixed it but thx
@@Night_YTistakenWc 😊
Thank you very much MajesticDev, I finally learned how to make a combat for my game, really, thank you very much, I've become a big fan of yours. Your channel was the only one that got me right! I love you from the heart.
Glad I could help!
@@MajesticUC the punch animation isnt playing
Man I love ur Vids they bring me so much joy as a new person to roblox studios
Very helpful! Thank you for this great tutorial, i modified it a bit and now it's perfect, i like it so far!
Glad it helped!
@@MajesticUC it didnt work for me and i dont know whats the problem
Wow this is the smoothest open source punch script I’ve ever Sean thank you
Thanks!
works great, glad i learned the basics first, makes it much better to understand
local cas = game:GetService("ContextActionService")
local rs = game:GetService("ReplicatedStorage")
local events = rs:WaitForChild("Events")
local hitboxEvent = events:WaitForChild("Hitbox")
local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local hum = character:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
local leftPunch = animator:LoadAnimation(script:WaitForChild("LeftPunch"))
local rightPunch = animator:LoadAnimation(script:WaitForChild("RightPunch"))
local currentPunch = 0
local lastPunch = 0
local debounce = false
local function punch()
if debounce then return end
if tick() - lastPunch > 1.5 then
currentPunch = 0
end
debounce = true
if currentPunch == 0 then
rightPunch:Play()
hitboxEvent:FireServer(Vector3.new(3,3,3), Vector3.new(2), 10, 0.3)
task.wait(0.4)
debounce = false
elseif currentPunch == 1 then
leftPunch:Play()
hitboxEvent:FireServer(Vector3.new(3,3,3), Vector3.new(2), 10, 0.3)
task.wait(0.4)
debounce = false
elseif currentPunch == 2 then
rightPunch:Play()
hitboxEvent:FireServer(Vector3.new(3,3,3), Vector3.new(2), 10, 0.3)
task.wait(0.8)
debounce = false
end
if currentPunch == 2 then
currentPunch = 0
else
currentPunch += 1
end
lastPunch = tick()
end
cas:BindAction("Punch", punch, true, Enum.UserInputType.MouseButton1)
-- SERVER SCRIPT ------------------------------------------------------------------
local rs = game:GetService("ReplicatedStorage")
local events = rs:WaitForChild("Events")
local hitboxEvent = events:WaitForChild("Hitbox")
function newHitbox(character, size, offset, damage, linger)
local hrp = character:FindFirstChild("HumanoidRootPart")
if hrp == nil then return end
local weld = Instance.new("WeldConstraint", hrp)
local hitbox = Instance.new("Part")
weld.Part0 = hrp
weld.Part1 = hitbox
hitbox.Transparency = 1
hitbox.CanCollide = false
hitbox.CanQuery = false
hitbox.Massless = true
hitbox.Size = size
hitbox.CFrame = hrp.CFrame + hrp.CFrame.LookVector * offset.X + Vector3.new(0,offset.Y)
hitbox.Parent = character
hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") == nil then return end
for _, v in pairs(hitbox:GetChildren()) do
if v:IsA("ObjectValue") then
if v.Value == hit.Parent then return end
end
end
local hitCounter = Instance.new("ObjectValue", hitbox)
hitCounter.Value = hit.Parent
hit.Parent.Humanoid:TakeDamage(damage)
end)
game.Debris:AddItem(hitbox, linger)
end
hitboxEvent.OnServerEvent:Connect(function(plr, size, offset, damage, linger)
newHitbox(plr.Character, size, offset, damage, linger)
end)
Edit: Also yes, I stole it from the paste bin.
tysm!
did i just write all the code and i didnt see that thank you so much😭😭
TYYY
Tysm for the code but when I punch the dummy it does nothing to it
you goddamn legend
i'll use this as reference since i've been trying to make a combat system with remote events, local scripts and scripts but it always bugged, thank you for uploading this since i had no consideration for bind action before this!!!
K
you helped so much with my fighting game and the tutorial is so short too!
thanks!
PunchScript (Localscript):
local cas = game:GetService("ContextActionService")
local rs = game:GetService("ReplicatedStorage")
local events = rs:WaitForChild("Events")
local hitboxEvent = events:WaitForChild("Hitbox")
local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local hum = character:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
local leftPunch = animator:LoadAnimation(script:WaitForChild("LeftPunch"))
local rightPunch = animator:LoadAnimation(script:WaitForChild("RightPunch"))
local currentPunch = 0
local lastPunch = 0
local debounce = false
local function punch()
if debounce then return end
if tick() - lastPunch> 1.5 then
currentPunch = 0
end
debounce = true
if currentPunch == 0 then
rightPunch:Play()
hitboxEvent:FireServer(Vector3.new(4,4,4), Vector3.new(2), 10, 0.3)
task.wait(0.4)
debounce = false
elseif currentPunch == 1 then
leftPunch:Play()
hitboxEvent:FireServer(Vector3.new(4,4,4), Vector3.new(2), 10, 0.3)
task.wait(0.4)
debounce = false
elseif currentPunch == 2 then
rightPunch:Play()
hitboxEvent:FireServer(Vector3.new(4,4,4), Vector3.new(2), 10, 0.3)
task.wait(0.8)
debounce = false
end
print(currentPunch)
if currentPunch == 2 then
currentPunch = 0
else
currentPunch += 1
end
lastPunch = tick()
end
cas:BindAction("Punch", punch, true, Enum.UserInputType.MouseButton1)
ServerScript (Normal Script):
local rs = game:GetService("ReplicatedStorage")
local events = rs:WaitForChild("Events")
local hitboxEvent = events:WaitForChild("Hitbox")
function newHitbox(character, size, offset, damage, linger)
local hrp = character:FindFirstChild("HumanoidRootPart")
if hrp == nil then return end
local weld = Instance.new("WeldConstraint", hrp)
local hitbox = Instance.new("Part")
weld.Part0 = hrp
weld.Part1 = hitbox
hitbox.Transparency = 1
hitbox.CanCollide = false
hitbox.CanQuery = false
hitbox.Massless = true
hitbox.Size = size
hitbox.CFrame = hrp.CFrame + hrp.CFrame.LookVector * offset.X + Vector3.new(0,offset.Y)
hitbox.Parent = character
hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") == nil then return end
for _, v in pairs(hitbox:GetChildren()) do
if v:IsA("ObjectValue") then
if v.Value == hit.Parent then return end
end
end
local hitCounter = Instance.new("ObjectValue", hitbox)
hitCounter.Value = hit.Parent
hit.Parent.Humanoid:TakeDamage(damage)
end)
game.Debris:AddItem(hitbox, linger)
end
hitboxEvent.OnServerEvent:Connect(function(plr, size, offset, damage, linger)
newHitbox(plr.Character, size, offset, damage, linger)
end)
thx so much life saviour
Thanks you're amazing
@@Lyrics4LifeOfficial no problem bro
Can someone tell me why the second punch keeps repeating
yo this was so helpful and straight to the point.
You just earned urself a sub my guy.
earned a sub thanks making my new fighting game rn :DDD
EVERYONE STRUGGELING TO MAKE THE PUNCH DO MORE DAMAGE HERE!!!:::
CHANGE THE PART WHERE IT SAYS TAKADAMAGE(100) TO THE AMOUNT YOU WANT!
BTW:THIS IS THE HITBOX SCRIPT
local rs = game:GetService("ReplicatedStorage")
local events = rs:WaitForChild("Events")
local hitboxEvent = events:WaitForChild("Hitbox")
function newHitbox(character, size, offset, damage, linger)
local hrp = character:FindFirstChild("HumanoidRootPart")
if hrp == nil then return end
local weld = Instance.new("WeldConstraint", hrp)
local hitbox = Instance.new("Part")
weld.Part0 = hrp
weld.Part1 = hitbox
hitbox.Transparency = 1
hitbox.CanCollide = false
hitbox.CanQuery = false
hitbox.Massless = true
hitbox.Size = size
hitbox.CFrame = hrp.CFrame + hrp.CFrame.LookVector * offset.X + Vector3.new(0,offset.Y)
hitbox.Parent = character
hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") == nil then return end
for _, v in pairs(hitbox:GetChildren()) do
if v:IsA("ObjectValue") then
if v.Value == hit.Parent then return end
end
end
local hitCounter = Instance.new("ObjectValue", hitbox)
hitCounter.Value = hit.Parent
hit.Parent.Humanoid:TakeDamage(damage)
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(100)
end)
game.Debris:AddItem(hitbox, linger)
end
hitboxEvent.OnServerEvent:Connect(function(plr, size, offset, damage, linger)
newHitbox(plr.Character, size, offset, damage, linger)
end)
hope this might make it even more usefull
also some animation id's of anims i made:
left:rbxassetid://14791654126
right:rbxassetid://14791354670
THE MOST W COMMENT
W this man
gte this man $1,000,000,000
also imsubbed
W mans
Also what is "hitBoxEvent" because that is the problem for me
@@Djredseaa Event from replicated storage
Thank you, this is the best tutorial on creating a fighting game that I have seen. I copied everything myself :)
ty
@@MajesticUC thank you! But how to do punching bag which can reset himself health after 3-5 sec after health == 0 what i need to do say pls i even did humanoid and homanoid root part in punching bag and did reset health after 3 sec but after 1 reset him health become 0 and i cant change it to 100
@@mason228x
Respawn script
local Copy = script.Parent:Clone()
local NPC = script.Parent
local Humanoid
for i,v in pairs(NPC:GetChildren()) do
if v:IsA('Humanoid') then
Humanoid = v
end
end
if Humanoid then
Humanoid.Died:Connect(function()
wait(5)
Copy.Parent = NPC.Parent
Copy:MakeJoints()
NPC:Destroy()
end)
else
warn('Cannot find Humanoid in Respawn Script!')
end
Omg i do really respect every developer, this remembers me how dumb i am 😢
im sure ur very smart
thank you so much i always had problems when trying to make a fighting system i subscribed
Cool
THANK YOU SOO MUCH I WENT THROUGH 10 TUTORIALS TRYNA DO THIS THANK U BRO
It dosent work on used the replit ai 10 time to try to fix it but no I can’t punch at all
same
SAME
SAMEEEEEEEEEEEEE
Same
Same
thank you for making the music so loud to the point where you cant hear anything. very helpful in a tutorial video.
tts?
Hey brain dead! Just copy the video or else mute the video and read! Don’t be lazy!
fr lol
wow very nessecesary\
I’m having guns,swords, knives, rocket launchers, maces, bows all that good stuff
I would recommend learning module scripts then
@MajesticUCwhat are those bro? cant gsearch rn
@@nexi1mus like settings in a script if that makes sense
Really good video dude, subbed.
Thx
Extremely Helpful video thanks so much. Helped me to learn a lot!
I spent 30 mins doing this and it dont work😭😭😭😭
Same lmao
Same🥲
real
SAME BRUH ):
@@wolfyoutubeidk same here but im pretty sure its because its an outdated script, the video was made a year ago
Got stuck on scripting the animation. I used r15 instead of r6, so did that mess it up perhaps; or did I just mess up somewhere in that void of code? I also used 8 different punch animations, so did that perhaps mess the whole thing up? idk anymore
as long as you used r15 animations and an r15 rig it should work fine. If you make 8 different animations you have to create 8 different variables and also store all of the anims (with their id's) inside the script.
@@MajesticUC What am i supposed to put in offset,size and that parameters,im using r6 and im new to developing sorry if im making you mad.
Why would i be mad? The parameters are just for the hitbox it doesnt matter whether you are r6 or r15
@@MajesticUC alright but what does offset,size and that stuff mean,like should i put 4,7,1 (width,height,depth amount of studs) in size? in offset what should i do?
Offset is a vector 3 and is the x distance and y distance the centre of the hitbox will be from the character. The size is a vector 3 and is the size of the hitbox, the damage is a number value and is just the amount of damage the hitbox deals and the linger is how long the hitbox exists for before it is destroyed. Also I put in the parameters for my hitboxes in the vid and in the pastebin
"first save the game to rawblox"💀💀💀💀💀
OMG TYSM I WAS LOOKING FOR HOURS TRYING TO FIND A WORKING TUTORIAL AND THIS ONE WORKS
I was wondering how to make it so that when you press the combat button there will be different animations like:
Punch, hook, kick, kick... repeat
i think that would be cooler and i would be very thankful if you made a tutorial for that
If you want something like that then that means you would need a different animation play for each tick punch that you are on so 1 would play punch 2 would play hook and so on
the m1's dont work?
yeah i tried it and it didn’t work too
Me to
Yah I wasted 2 hours
For me it dont work
How this dude feels after saying the combat system doesn't work instead of checking the bug finder and using problem solving skills to figure out the conflict
@@zachPlushgaminghe is right. The animations work perfectly, its the hitbox.
My code has no errors, but the output doesnt do anything.
@BluHat_ adjust the hitbox then? He showed you how to
@@zachPlushgaming yeah i did and its doesnt show up at all. The script is probably outdated.
@@BluHat_ did you make sure you didn't make it transparent???
finally an actually working combat system ( i was looking for a tool but it works too)
OMG tysm! This is a very good tutorial that I can also understand! U deffo earned a subscribtion from me!1!!1
Thanks for subbing!
Jesus is the LORD
LMAOOOOOO ikr
Fr
Yes
I agree with this statement
No
hehehehaw
THANK YOU SO MUCH YOUR LIKE THE ONLY GUY THAT SHOWS US HOW
Yo thx for the help bro I needed it 😊
Thank you for this. Im having some issues with animations but it doesnt have anything to do with the code so THXXXXX
Thank god someone have a pastebin..
This is so helpful man..
Keep up your post ❤❤
W it took me 30min to do and the result is good tysm!!
Loved the vid Ty so much bro
np
How would I go about making a sound for the game? Do I have to make it myself, does Roblox have sounds that are avalible, or can I get it from other players? Please, and Thank you.
yo bro i got somthing to say
You earned another sub💝💝
i found out it said Hitbox instead of HitBox I finally figured it out Very helpful!
i love you bro this tutorial saved my life
okay update didnt work.
seems like this part
hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") == nil then return end
for _, v in pairs(hitbox:GetChildren()) do
if v:IsA("ObjectValue") then
if v.Value == hit.Parent then return end
end
end
print("hitbox.touched v in pairs")
local hitCounter = Instance.new("ObjectValue", hitbox)
hitCounter.Value = hit.Parent
hit.Parent.Humanoid:TakeDamage(damage)
print("damage")
end)
game.Debris:AddItem(hitbox, linger)
end
isnt working
tested a bit more with print and its only that part that doesnt work
4:32 i was tweaking out for an hour because the animation would have gone Right punch, left punch, right punch and right punch you need to do
''If currentPunch == 2 then
currentPunch = 1''
After 5 hours of searching this is the one. It took me around 1-2 hours to learn. I thank you for this!
Im subscribed. You are also better than thedevking man
this is the local script if your too busy to write it, but its broken. can someone maybe fix it and reply with it fixed in the comments please?? ty
local cas = game:GetService("ContextActionService")
local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local hum = character:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
local leftPunch = animator:LoadAnimation(script:WaitForChild("LeftPunch"))
local rightPunch = animator:LoadAnimation(script:WaitForChild("RightPunch"))
local currentpunch = 0
local debounce = false
local function punch()
if debounce then return end
debounce = true
if currentPunch == 0 then
rightPunch:Play()
task.wait(0.4)
debounce = false
elseif currentPunch == 1 then
leftPunch:Play()
task.wait(0.4)
debounce = false
elseif currentPunch == 1 then
leftPunch:Play()
task.wait(0.4)
debounce = false
elseif currentPunch == 2 then
rightPunch:Play()
task.wait(0.8)
debounce = false
end
if currentPunch == 2 then
currentPunch = 0
else
currentPunch += 1
end
end
cas:BindAction("Punch", punch, true Enum.UserInputType.MouseButton1)
In the last line there is a code error that I don't have enough skills to fix LOL,
the last line (fixed) is: cas:BindAction("Punch", punch, true, Enum.UserInputType.MouseButton1)
@@GermanBruv thanks bro
could you please do a tutorial on punch-stun and the hit-animations the person whos getting hit has
Was complicated but worth it
Thanks for explaining the stuff i hate the copy and paste stuff its nice to learn
Only one that worked tysm man
this sadly didnt work for me when i get in to test if i could punch nothing happened :/
becuase of the names check if your hit box write Hitbox with capital latter and rightpunsh with capital latter in P and R
I want the damage to be as much as a stat. Its called Power, its in leaderstats inside of player. But idk how to acces the plr in that script
i was watching this video and then i realised i dont have the patience to do all this espesially when you dont explain a lot of the stuff like how to get the moon animator or what im supposed to type in the script but you seemed to help other ppl but i might just go back to making free model games
I hope you get everything in life thank you so much, the tick() m1 resset was super useful for what I needed.
Omg Thx! this helped me so much
at 2:57 how do i put the animations into the punchscript
IT HELPED A LOT TY DUDEEE
FIRST GOOD VIDEO I SAW OF ROBLOX STUDIO bc other are... u know what i mean
i know the video 9 months ago but still i copied the whole punch script but it didnt work, and i have ZERO idea why
all i get is the "ServerScriptService.Hitbox' :41: Expected 'end' (to close 'function' at line 40), got
you're great at this
I like how 100% of this video is the tutorial and everything he say it useful and important this really helped me
when i clicked on the animation it didnt show the anim id thing so i couldn't put in id anywhere.
same
SAME BRUH
Did you put the right object?
SAME
Nvm
how do i fix the PlayerGui.PunchScript:5: attempt to index nil with 'Character' - Server - PunchScript:5
here are my 5th code line:
local character = plr.Character or plr.CharacterAdded:Wait()
😎
@@MajesticUC what
thank you very much for helping me but i have a doubt about how to make a defense system do you have any idea how i can do it?
Wdym by defence system?
@@MajesticUC An example I press "E" to defend the opponent's punch, I don't know how to do it so if you can help me I'd appreciate it bro
2:36 lets start scripting! Then throws a mayhem with the folders and i dont understand anything
I cant beleive it took that long to make punch animation the suffer of tsb dev is crazy
If you equip a tool/ item, does it stop the script? If not how can I make it do that
I have done what you said to do up to the 4:39 mark but my animation won’t work when I left click my my mouse😢. Does anyone have any recommendations that could help me get my animation to start playing 🙏
thanks for the tutorial it works but when i do a punch it randomly teleports me can u help me?
Is there a way you can change the hit button to something else for mobile players?
My punch animation doesn't work i already copy and paste the id but it doesn't work can anybody help ?
I have a question do I have to do the beginning first then copy and paste the paste bin
My animation won’t play😢
My Punch Script line 3 the output say player is not a valid member of "DataModel" What should i do please help.
What is datamodel in your explorer?
Every time I try adding the hitbox code it always doesn't load up the animation and the hitbox part, could you help me what i should do?
please i hope you will answer, so in my game i have a character selection system, and i want each character to have a different punch animation, hitbox size, etc.. please help me!
I dont know why but my hitbox isn't showing at 7:15 please someone help me
happened to me too
ur hitbox's transparency is at 1, turn it to 0 to make it visible :)
Do i need to the transparency to 0 in the script or how ?
Good Work! Is Help my game
How do I add punch animations into the local script?
hold down shift.. and select the stuff.. drag it into the local script............... you dont even have to hold shift if you want..
srry dident work@@LO0IC
for some reason, when I run the test, I can hit only 2 times in the script there are no errors.. and hit boxes don't want to work at all(
i only started working on studio a couple days ago, and today i encountered a problem with this.
so, when i finished typing all of that up to 4:33 i tested it and when i saved it said it was uncommitted? it didnt work either? could someone tell me whats wrong?
If u cant understand any code or only know the absolute basics then u shouldnt be attempting to make a fighting game
Quick question!where is the submit for asset configuration cause I don’t see it on mine
Very good tutorial!
My punch animation will only play the first time I click then dosnt work
i copy'd everything and i dont know why but the damage is not working ;-;
Me too
I am a complete noob in developing so I have question how do I change punch from mouse button to "F"
instead of user input type then do KeyCode == Enum.KeyCode.F
amazing video, how to i make it so you can only punch when a round starts in my game tho
I have an issue where whenever I m1 the animation plays at kind of half proportions, the punch starts halfway up the body, it goes half as far, etc, does anyone know how to fix this?
same
@@ultrol8223 I found out how to fix it, you need to change the priority to action then save it to Roblox again and use the new ID
If the animation is to fast that’s why make it where your guy is in the defalt position at the end of one sec
can you make for both r15 game that looks like arsenal and cw
This will work on r15 as well.
if you want to do it in R15 it's the same but with R15 animations and also all the avatars in R15
Can you delete the animation in the animation editor if you have it saved for another animation you wanna make btw you earned a sub
i can't seem to get anything to work, i have followed every bit of code that you wrote up too 4:33 and then from there nothing will play, no animations at all. i even tried to redo all the code and that didn't work. the pastebin one isn't working either. i have done everything you said to do but nothing is showing. Any help please would be nice :)
🤷♀️
@@MajesticUC do you know why I can’t see the hit box?
@@Hehelol3321 cos its invisible? or maybe it just isnt spawning in idk. Did you set transparency to 1?
@@MajesticUC omg it works I’m subscribing
your coding style is quite unique
Anyone know why when I hit the dummy it does nothing? Please and Thank you.
nvm I figured it out
How’d u do it ?
@@daiu3d596 I'm pretty sure it was due to my animation priority
Pls help i cant add punch id to my left and right punch
even though im 4 months late, you helped me alot earned a sub!