Heavy Punch Ability Not Doing Anything On Key Press

This is a repost, because nobody had even seen the last one within 5 days.

So, I’m trying to make a JoJo game, and currently have used a scripting tutorial by RED Plys on YouTube. Problem is, the tutorial stopped on barraging, so I have no Heavy Punch. When trying to make my own, it didn’t happen.

In short, I need help making an ability.

I would show a video of it not working, but there aren’t any errors in the output, and pressing the keybind won’t do anything at all, so a video wouldn’t make sense.

I have two scripts.
Here is the local one, located in StarterPack:

local Player = game:GetService("Players").LocalPlayer

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Heavy = ReplicatedStorage:WaitForChild("Heavy")

local UIS = game:GetService("UserInputService")

local debounce = false
local isActive = false
local cd = 6.25

UIS.InputBegan:Connect(function(input, isTyping)
	if isTyping then
		return
	elseif input.UserInputType == Enum.KeyCode.R then
		if debounce == false and isActive == false then
			debounce = true
			isActive = true

			Heavy:FireServer(isActive)
		end
	end
end)

Heavy.OnClientEvent:Connect(function()
	wait(cd)
	debounce = false
	isActive = false
end)

Here is the second script, a regular script located in ServerScriptService.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Heavy = ReplicatedStorage:WaitForChild("Heavy")

local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local Meshes = script:WaitForChild("Meshes")

local SSS = game:GetService("ServerScriptService")
local Library = SSS:WaitForChild("Library")
local DictionaryHandler = require(Library:WaitForChild("DictionaryHandler"))

local Damage = 10

local plrsHit = {}

function doDamage(Character, humrp, Folder)
	local Hitbox = Meshes:WaitForChild("Hitbox"):Clone()
	Hitbox.CFrame = humrp.CFrame * CFrame.new (0,0,-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 = weld.Part0

	Hitbox.Touched:Connect(function(Hit)
		if Hit:IsA("BasePart") then
			if not Hit:IsDescendantOf(Character) then
				local enemyHum = Hit.Parent:FindFirstChild("Humanoid")
				local enemyHumRP = Hit.Parent:FindFirstChild("HumanoidRootPart")

				if enemyHum and enemyHumRP then
						Hitbox:Destroy()

						enemyHum:TakeDamage(Damage)

						if not plrsHit[enemyHum] then
							DictionaryHandler.addTo(enemyHum, "Stunned")

							plrsHit[enemyHum] = 30

							while wait(0.01) do
								if plrsHit[enemyHum] > 0 then
									plrsHit[enemyHum] -= 1
								else
									plrsHit[enemyHum] = nil
									DictionaryHandler.removeFrom(enemyHum, "Stunned")

									break
								end
							end
						elseif plrsHit[enemyHum] then
							plrsHit[enemyHum] = 30
						end
				end
			end
		end
	end)

end

Heavy.OnServerEvent:Connect(function(Player, isActive)
	local Character = Player.Character
	local Humanoid = Character.Humanoid
	local HumanoidRP = Character.HumanoidRootPart

	if not DictionaryHandler.findPlayer(Humanoid, "Stunned") and not DictionaryHandler.findPlayer(Humanoid, "Blocking") and not DictionaryHandler.findPlayer(Humanoid, "Ability") then
		if isActive then
		local Stand = Character:FindFirstChild("Dummy")
		if Stand then
			local AnimControl = Stand:FindFirstChild("AnimControl")
			if AnimControl then
				local Controller = Stand.PrimaryPart:FindFirstChild("StandWeld")
				if Controller then
					local goal = {}
					goal.C0 = Controller.Part0.CFrame:ToObjectSpace(Controller.Part1.CFrame)
					goal.C1 = Controller.Part0.CFrame:ToObjectSpace(Controller.Part1.CFrame * CFrame.new(0,0.25,-2))
					local info = TweenInfo.new(.1)
					local tween = TweenService:Create(Controller,info,goal)
					tween:Play()
					Stand.HumanoidRootPart.Punch:Play()

					local Action

					local HumanoidType = AnimControl:FindFirstChild("HumanoidType")
					if HumanoidType.Value == "R15" then
						Action = AnimControl:LoadAnimation(script.HeavyAnim)
					end
					Action:Play()

					local Folder = Instance.new("Folder", workspace)
					Folder.Name = "Effects"
					Debris:AddItem(Folder, .5)

					local stand_HumanoidRP = Stand:FindFirstChild("HumanoidRootPart")

					doDamage(Character, stand_HumanoidRP, Folder)

					Action.Stopped:Connect(function()
						if not DictionaryHandler.findPlayer(Humanoid, "Blocking") then
							wait(.1)
							local goal = {}
							goal.C0 = Controller.Part0.CFrame:ToObjectSpace(Controller.Part1.CFrame)
							goal.C1 = Controller.Part0.CFrame:ToObjectSpace(Controller.Part1.CFrame * CFrame.new(3,1,2))
							local info = TweenInfo.new(.25)
							local tween = TweenService:Create(Controller,info,goal)
							tween:Play()
						end

						Heavy:FireClient(Player, true)
					end)
				end
				end
			end
		else
			Heavy:FireClient(Player, false)
		end
	else
		Heavy:FireClient(Player, false)
	end
end)

Thank you in advance to anyone who’s able to help out!

This script from the tutorial has a lot of potential for silent errors.

All those if statements have the potential to fail silently if the setup is not correct or there are outside script factors.

Your first step should be to print debug or put warnings to see where the code fails at each if statement.

so this worked but in the other script

apparently it has to be

input.KeyCode == Enum.KeyCode.R

and not

input.UserInputType == Enum.KeyCode.R

Thank you for helping! Not sure which comment to mark as the solution now, though.
I’ll just mark yours.

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