Alright, so the title is self explanatory so the main issue is that the touched event isn't firing when one of three parts of an arm are touching a object.
So it's basic just a touched event and checking if it has a humanoid etc,. Nothing wrong there with the script. It's the actual collision detection with the arm and the part.
I don't want to move on to more risky methods(such as loops) without consultation from more experienced members.
If you want the script here is the pastebin (I know it's pretty bad it's just a draft script until I figure out what the problem is)
The event is firing I made it print, so put that off the list. The functions are being called so that is good.
Also to take note is the touched event rarely fires. I extended the "wait(.3)" time to see if it improves but it doesn't prove to be reliable. When I speak of unreliable I talk about where it has these gaps where it would stop working consistently for a certain amount of time before working again.
Unless I'm being a bit spoiled about how I want it to work I would like some advice on how to improve it to almost a 90% success rate of collision.
Thanks for reading and especially thanks if you decide to help out.
Alright, so my game itself has something similar. I won't be writing the whole script cause I'm at school but there are a few things you should know and label out.
First think about how long your punch animation is. You wanna keep the animations all the same time length. For example, a right punch is 0.5 seconds, the left punch and left kick and right kick would have to be 0.5 seconds for it all to be smooth.
Now you need some sort of way to detect if you are doing a left punch, a right punch, a left kick, or, a right kick.
Now instead of using so many listeners, just use a table like so:
local LeftPunchParts = { 'LeftHand' 'LeftUpperArm' 'LeftLowerArm' } for _, Part in pairs(LeftPunchParts) do Char[Part].Touched:Connect(function(h) -- blah end) end
- To set this fully up you will want a debounce and some variables
local TouchDebounce = true local CurrentAction = nil local plr = game.Players.LocalPlayer -- if local script local Char = plr.Character or plr.CharacterAdded:Wait() local LeftPunchParts = { 'LeftHand' 'LeftUpperArm' 'LeftLowerArm' } local RighPunchParts = { 'RightHand' 'RightUpperArm' 'RightLowerArm' } -- add tables for kicks if u want local function CheckAction() -- here you shall determine what punch / kick it is CurrentAction = -- put current action here end UserInputService CheckAction() -- checking the action will set the CurrentAction var -- play animation if CurrentAction = 'Left Punch' then for _, Part in pairs(LeftPunchParts) do Char[Part].Touched:Connect(function(h) if TouchDebounce then TouchDebounce = false -- this will be leftarm wait(0.5) -- seoncds of animation or cooldown TouchDebounce = true end end) end end end)
This should be your basic set up.
Hopefully this gave you an idea of what to do. Now I must go back to school.
Best of luck developer!