It doesnt do uppercut

repeat task.wait() until game:IsLoaded()
local players = game:GetService("Players")
local rs = game:GetService("ReplicatedStorage")
local uis = game:GetService("UserInputService")

local lp = players.LocalPlayer
local char = lp.Character or lp.CharacterAdded:Wait()
local hum:Humanoid = char:WaitForChild("Humanoid")
local hrp:Part = char:WaitForChild("HumanoidRootPart")
local Animator:Animator = hum:WaitForChild("Animator")

local Fightanims = rs.Assets.Animation.Combat.Fist
local HitboxPart = rs.Assets.Hitbox
local RemoteHitbox = rs.Assets.Remotes.Hitbox

local Block = Fightanims.Block
local Downslam = Fightanims.Downslam
local Uppercut = Fightanims.Uppercut

local anim = {
	Animator:LoadAnimation(Fightanims.M1),
	Animator:LoadAnimation(Fightanims.M1_2),
	Animator:LoadAnimation(Fightanims.M1_3),
	Animator:LoadAnimation(Fightanims.M1_4),
}


local BlockLoaded = Animator:LoadAnimation(Block)
local UppercutLoaded = Animator:LoadAnimation(Uppercut)

local Jumptick
local Isincombat = false
local current = 1
local now = tick()
local db = false
local DebounceChar = {}
local IsBlocking = false
local BlockWalkspeed = 10

local tool = script.Parent

function Hitbox(WhatType)
	local current = HitboxPart:Clone()
	current.Parent = workspace
	current.CFrame = hrp.CFrame * CFrame.new(0,0,-2.5)
	local Params = OverlapParams.new()
	Params.FilterDescendantsInstances = {char,tool}
	Params.FilterType = Enum.RaycastFilterType.Exclude
	--local HitType = WhatType
	print(WhatType)
	
	task.spawn(function()
		local s,e = pcall(function()
			--print(WhatType)
			for i,v in pairs(workspace:GetPartsInPart(current,Params)) do
				if v.Parent:FindFirstChildOfClass("Humanoid") then
					local echar:Model = v.Parent
					local ehum = echar:FindFirstChildOfClass("Humanoid")
					local ehrp:Part = echar:FindFirstChild("HumanoidRootPart")
					if echar and not DebounceChar[echar] then
						warn(WhatType)
						warn(echar.Name)
						if WhatType == "Uppercut" then
							print(#workspace:GetPartsInPart(current,Params))
							DebounceChar[echar] = true
							RemoteHitbox:FireServer("Damage",echar,ehum,current,IsBlocking)
							--ehrp.CFrame:Lerp(ehrp.CFrame * CFrame.new(0,2,2))
							print("Succesfully done uppercut")
							task.wait(.4)
							--return ehum
						else
							DebounceChar[echar] = true
							RemoteHitbox:FireServer("Damage",echar,ehum,current,IsBlocking)
							task.wait(.4)
						end
					end
				end
			end
			DebounceChar = {}
			
		end)
		if not s then
			warn("Hitbox failed",e)
		end
	end)
	game:GetService("Debris"):AddItem(current,.4)
end


tool.Activated:Connect(function()
	if db == false and not IsBlocking and not char:GetAttribute("Stunned") then
		db = true
		local passedtime = tick() - now
		if passedtime > 1 then
			--print("Passed time?")
			Isincombat = false
			current = 1
			now = tick()
			db = false	
		else
			if current <= 4 then
				Isincombat = true
				Jumptick = tick()
				now = tick()
				local a = anim[current]
				Hitbox()
				a:Play()
				task.wait((a.Length - 0.2))
				current += 1
				if current == 5 and uis:IsKeyDown(Enum.KeyCode.Space) then
					print("Has Tried to do  uppercut")
					UppercutLoaded.Priority = Enum.AnimationPriority.Action4
					UppercutLoaded:Play()
					Hitbox("Uppercut")
					--print(ehum.Parent.Name)
					task.wait(.8)
					return
				end
				db = false
			else
				current = 1
				now = tick()
				task.wait(.45)
				db = false
				Isincombat = false
			end
		end
	end
end)


uis.InputBegan:Connect(function(input, gpe)
	if gpe then return end
	if input.KeyCode == Enum.KeyCode.F then
		IsBlocking = true
		BlockLoaded:Play()
		RemoteHitbox:FireServer("BlockOn")
		hum.WalkSpeed = BlockWalkspeed
	end
end)

uis.InputEnded:Connect(function(input, gpe)
	if gpe then return end
	if input.KeyCode == Enum.KeyCode.F then
		IsBlocking = false
		BlockLoaded:Stop()
		RemoteHitbox:FireServer("Blockoff")
		hum.WalkSpeed = 16
	end
end)

uis.JumpRequest:Connect(function()
	if Isincombat then
		--print("Couldnt Jump")
		hum.Jump = false
	end
end)


--local testanim = workspace.Dummy.Humanoid.Animator:LoadAnimation(Uppercut)
--testanim.Looped = true
--testanim:Play()

At the hitbox function when i warn(whattype) it doesnt warn but before it does warn i tried to do everthing to fix it but it doesnt work. It returns constanly nil what ever i do.

Try this:

	local HB_current = HitboxPart:Clone()
	HB_current.Parent = workspace
	HB_current.CFrame = hrp.CFrame * CFrame.new(0,0,-2.5)
	local Params = OverlapParams.new()
	Params.FilterDescendantsInstances = {char,tool}
	Params.FilterType = Enum.RaycastFilterType.Exclude
	--local HitType = WhatType
	print(WhatType)

	task.spawn(function()
        local s,e = pcall(function()
            for i,v in pairs(workspace:GetPartsInPart(HB_current,Params)) do
                if v.Parent:FindFirstChildOfClass("Humanoid") then
                    local echar:Model = v.Parent
                    local ehum = echar:FindFirstChildOfClass("Humanoid")
                    local ehrp:Part = echar:FindFirstChild("HumanoidRootPart")
                    if echar and not DebounceChar[echar] then
                        warn(WhatType)
                        warn(echar.Name)
                        if tostring(WhatType) == "Uppercut" then
                            DebounceChar[echar] = true
                            -- Move the enemy up and forward for uppercut
                            if ehrp then
                                local moved = false
                                if echar:IsA("Model") then
                                    local ok, result = pcall(function()
                                        local newCFrame = echar:GetPivot() * CFrame.new(0, 2, 2)
                                        echar:PivotTo(newCFrame)
                                    end)
                                    if ok then
                                        moved = true
                                    end
                                end
                                if not moved then
                                    -- Fallback: move just the HumanoidRootPart
                                    ehrp.CFrame = ehrp.CFrame * CFrame.new(0, 2, 2)
                                end
                            end
                            print("Successfully done uppercut")
                            task.wait(.4)
                        else
                            DebounceChar[echar] = true
                            task.wait(.4)
                        end
                    end
                end
            end
            DebounceChar = {}
        end)
        if not s then
            warn("Hitbox failed",e)
        end
    end)
    game:GetService("Debris"):AddItem(HB_current,.4)
end```

It still doesnt work when i added tostring even when i print it it returns nil

I can look into more when I get the time. :grin:

you forgot to add in a string when using the function

at the tool.Activated, the function has a blank string, so it would return nil

simply to fix this, replace Hitbox() with Hitbox(“Uppercut”)

That wasnt the issue it was supossed to be blank on the first hitbox function but not the second.
I already got a fix for it by adding repeat task.wait() until WhatType ~= nil after if echar and not DebounceChar[echar] then
So thank u guys for your help.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.