My combat works in studio, but in game it doesn't?

I cannot comprehend. Quite literally I had multiple instances where I had my actual friend hop in game, play with me, and it didn’t work.


It simply doesn’t make any sense to me. Everything in the Studio worked and in game less than half of the things work the way I want them to.

can i see the detection script? Most commonly issue is that the player dont disconnect a function before destroying it

1 Like
-- \\ GetService Variables //--

local RS = game:GetService("ReplicatedStorage")

local SSS = game:GetService("ServerScriptService")

local Combat = RS:WaitForChild("Combat")

local Combat_Handler = require(script.Combat_Handler)

-- \\ Module Variables // --
local DicHandler = require(SSS:WaitForChild("DictonaryHandler"))

-- \\ Variables // --

local Damage = 5

-- \\ Functions //--

Combat.OnServerEvent:Connect(function(Player, sequence)
	
	local Character = Player.Character
	local Humanoid = Character.Humanoid
	local Humrp = Character.HumanoidRootPart
	
	if not DicHandler.find(Character, "Stunned") or DicHandler.find(Character, "LongStun") then
		local Action, Length = Combat_Handler.getAnimation(Humanoid, sequence)
		----print("Anims Playing")
		Action:Play()

		Action:GetMarkerReachedSignal("Hitbox"):Connect(function()
			Combat_Handler.CreateHB(Player, Character, Humrp, Length, sequence)
		end)

		wait(Length)

		if string.len(sequence) < 4 then
			Combat:FireClient(Player, false)
		else
			Combat:FireClient(Player, true)
		end
	else
		Combat:FireClient(Player, false)
	end
	
	
end)
function Combat_Handler.CreateHB(Player, Character, Humrp, sequence, Damage)
	local Folder = Instance.new("Folder", workspace)
	Folder.Name = Player.Name.."Combat"
	Debris:AddItem(Folder, 0.25)

	Hitbox = Meshes.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

	local pos1 = Hitbox.Position - (Hitbox.Size/2)
	local pos2 = Hitbox.Position + (Hitbox.Size/2)
	Re3 = Region3.new(pos1, pos2)
	end

function Combat_Handler.DamageHandler(Player, Character, Humrp, sequence, damage)
	--Region3 In Action
	local HBFinder = workspace:FindPartsInRegion3(Re3, Hitbox, 20)
	Debris:AddItem(Hitbox, 0.3)
	for i, parts in pairs (HBFinder) do
		if parts.Parent:FindFirstChild("Humanoid") and parts.Parent ~= Character then
			local enemyHumanoid = parts.Parent.Humanoid


			if Combat_Handler.playersincombat[Character] or DicHandler.find(Character, "Stunned") then
				return
			end
			enemyHumanoid:TakeDamage(damage)
			local duration
			if string.len(sequence) > 4 then
				duration = Length * 2
			else
				duration = Length * 3 -- After the combo is finished make the stun a little longer
			end

			if not Combat_Handler.playersincombat[enemyHumanoid] then
				Combat_Handler.playersincombat[enemyHumanoid] = os.clock()
				Combat_Handler.playerstuntime[enemyHumanoid] = duration
				DicHandler.add(enemyHumanoid.Parent, "Stunned")

				enemyHumanoid.WalkSpeed = 4
				enemyHumanoid.JumpPower = 0
			else
				Combat_Handler.playersincombat[enemyHumanoid] = os.clock()
				Combat_Handler.playerstuntime[enemyHumanoid] = duration
				
				enemyHumanoid.WalkSpeed = 16
				enemyHumanoid.JumpPower = 50
			end


		end
		
		break
	end-- If statement ended in forloop
end



RunService.Heartbeat:Connect(function()
	for _,Players in pairs(People:GetChildren()) do
		if Combat_Handler.playersincombat[Players] then
			local currtime = Combat_Handler.playersincombat[Players]
			local stuntime = Combat_Handler.playerstuntime[Players]
			if os.clock - currtime >= stuntime then
				Combat_Handler.playersincombat[Players] = nil
				Combat_Handler.playerstuntime[Players] = nil

				Players.Humanoid.WalkSpeed = 16
				Players.Humanoid.JumpPower = 50

				DicHandler.remove(Players, "Stunned")
			end
		end
	end
end)