Here’s the local script
local rp = game:GetService("ReplicatedStorage")
local Combat = rp:WaitForChild("Combat")
local UIS = game:GetService("UserInputService")
local debounce = false
local cd = {0,1}
local sequence = ""
local curr = 0
local prev = 0
UIS.InputBegan:Connect(function(Input,IsTyping)
if not IsTyping then
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
if debounce == false then
debounce = true
curr = os.clock()
local PT = curr - prev
if PT < 1 then
sequence = sequence.."L"
if string.len(sequence) > 5 then
sequence = "L"
end
else
sequence = "L"
end
Combat:FireServer(sequence)
end
end
end
end)
Combat.OnClientEvent:Connect(function(bool)
prev = curr
if bool then
wait(cd[2])
debounce = false
else
debounce = false
end
end)
.
Here’s Server script
local rp = game:GetService("ReplicatedStorage")
local Combat = rp:WaitForChild("Combat")
local Combat_Handler = require(script.Combat_Handler)
Combat.OnServerEvent:Connect(function(Player,sequence)
local Character = Player.Character
local Humanoid = Character.Humanoid
local Humrp = Character.HumanoidRootPart
local Action,Length = Combat_Handler.getAnimation(Humanoid,sequence)
Action:Play()
Action:GetMarkerReachedSignal("Folder"):Connect(function()
Combat_Handler.create(Player,Character,Humrp)
end)
wait(Length)
if string.len(sequence) < 5 then
Combat:FireClient(Player,false)
else
Combat:FireClient(Player,true)
end
end)
.
Here’s Module script
local Animations = script.Animation
local KeyProvider = game:GetService("KeyframeSequenceProvider")
local Meshes = script.Meshes
local Debris = game:GetService("Debris")
local Combat_Handler = {
MeleeAnims = {["L"] = Animations.Melee1,
["LL"] = Animations.Melee2,
["LLL"] = Animations.Melee3,
["LLLL"] = Animations.Melee4,
["LLLLL"] = Animations.Melee5
}
}
function Combat_Handler.getAnimation(Humanoid,sequence)
local length = 0
local keysequence = KeyProvider:GetKeyframeSequenceAsync(Combat_Handler.MeleeAnims[sequence].AnimationId)
local keyframes = keysequence:GetKeyframes()
for i=1, #keyframes do
local Time = keyframes[i].Time
if Time > length then
length = Time
end
end
return Humanoid.Animator:LoadAnimation(Combat_Handler.MeleeAnims[sequence]),length
end
function Combat_Handler.create(Player,Character,Humrp)
local Folder = Instance.new("Folder")
Folder.Parent = workspace
Debris:AddItem(Folder,0.25)
local Hitbox = Meshes.Hitbox:Clone()
Hitbox.CFrame = Humrp.CFrame * Humrp.CFrame.LookVector * 2
Hitbox.Parent = Folder
local Weld = Instance.new("ManualWeld")
Weld.Part0 = Hitbox
Weld.Part1 = Humrp
--Weld.C0 = Weld.Part0.CFrame:ToObjectSpace(Weld.Part1.CFrame)
Weld.Parent = Humrp
local connection
connection = Hitbox.Touched:Connect(function()end)
local results = Hitbox:GetTouchingParts()
coroutine.wrap(function()
for i, obj in pairs(results) do
if not results[i]:IsDescendantOf(Character) then
local ehumanoid = results[i].Parent:FindFirstChild("Humanoid")
if ehumanoid and ehumanoid.Health > 0 then
Hitbox:Destroy()
if connection then
connection:Disconnect()
end
ehumanoid:TakeDamage(10)
break
end
end
end
end)()
task.delay(0.25,function()
if connection then
connection:Disconnected()
end
end)
end
return Combat_Handler
.
This is the toturial i followed.
But the problem is that whenever i click the animation works fine but the hitbox dosen’t come out i’m not sure why but i don’t see other having this problem when i scrolled down and read this video’s comments.
It should be working like this.
https://gyazo.com/cc399110de8602af8f3efa50768c870a
This is how mine works.
https://gyazo.com/cc399110de8602af8f3efa50768c870a
The hitbox dosen’t come out. I checked trough the workspace and couldn’t find my hitbox at all.
This is where i put the hitbox and the animations just like in the video nothing wrong. I’ve checked for a few times already.
So if you know what is causing the problem please tell me.
(I may answer your replies late,Sorry)