UserInputService.InputBegan firing twice

I am currently working on a game that is getting close to being releasable, but I noticed an issue in my combat system, UIS.Inputbegan is firing twice, I have two scripts that I plan on merging, they both use UserInputService.InputBegan. I thought that maybe that was why it was running twice so I place a different print in each and both prints printed twice. This is an issue because in the combat system the damage and effects are done on the server side via a remote event, well the remote event is firing twice making the character to twice the damage, because the script is being run twice. I tested on another device to see if it was my keyboard that was acting up, but it wasn’t. I’ve tried everything I can think of so if you have any ideas, I could really use the help thank you.

I am trying to avoid posting the whole code because its almost 600 lines, but if I need to I can.

UserInputService.InputBegan:Connect(function(input, gpe)

      print("input")

     --Several if statements and over stuff--

end)
2 Likes

print(input.UserInputType)

You will see why it’s firing multiple times. There are all different types… keyboard, mouse clicks, movement of the mouse, etc.

I just tried what you said, and its still printing twice and they were the same if I pressed a button it said

Enum.UserInputType.Keyboard
Enum.UserInputType.Keyboard

If I moved the Camera is said

Enum.UserInputType.Focus
Enum.UserInputType.Focus

and so on

and like I said there were two scripts that used inputbegan, I put the (print(input.UserInputType)) in only one of them

Thats likely the case, you would Basically have Two Connections to fire when the Player does something.

Can you show your entire script, please? This is too little information for me to help you out here. Also

This won’t print the input value of the function since you’ve made print print a string, not a value.

I tried disabling one of them, and no luck. The print was only in one of the scripts.

I made print a string on purpose, if you try to print the input without using keycode or userinputtype it just prints “InputObject”

Yeah sorry, just letting you know. I thought you’d done that by accident.

The full script is really long. Its also a mess because Im still working on it. but here it is:

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character.Humanoid

local statusFolder = character:WaitForChild("StatusFolder")

local uis = game:GetService("UserInputService")
local ts = game:GetService("TweenService")

local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Whitelist
params.FilterDescendantsInstances = {workspace.Map}

local remote = game.ReplicatedStorage.CombatEvent

local LastTimeM1 = 0
local LastM1End = 0
local combo = 1

local blocking = false
local canAir = true

local punchAnims = {
	
	"rbxassetid://11967384879",
	"rbxassetid://11965741396",
	"rbxassetid://11968253783",
	"rbxassetid://11978496178",
	"rbxassetid://11978551893",
	
}

local blockAnims = {
	
	"rbxassetid://11991966762"
	
}

local airAnims = {
	
	"rbxassetid://11968348350",
	"rbxassetid://11969785324"
}

local UserInputService = game:GetService("UserInputService")
local localPlayer = game.Players.LocalPlayer

local canDoubleJump = false
local hasDoubleJumped = false
local oldPower
local TIME_BETWEEN_JUMPS = 0.2
local DOUBLE_JUMP_POWER_MULTIPLIER = 1.4

function onJumpRequest()
	if not character or not humanoid or not character:IsDescendantOf(workspace) or
		humanoid:GetState() == Enum.HumanoidStateType.Dead then
		return
	end

	if canDoubleJump and not hasDoubleJumped then
		hasDoubleJumped = true
		humanoid.JumpPower = oldPower * DOUBLE_JUMP_POWER_MULTIPLIER
		humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
	end
end

local function isinparty(plr, hit)
	for i,v in pairs(game.Players:GetChildren()) do
		if v:FindFirstChild("Party") then
			if v:FindFirstChild("Party"):FindFirstChild(plr) and v:FindFirstChild("Party"):FindFirstChild(hit) then
				return true
			end
		end
	end
end

local function characterAdded(newCharacter)
	character = newCharacter
	humanoid = newCharacter:WaitForChild("Humanoid")
	hasDoubleJumped = false
	canDoubleJump = false
	oldPower = humanoid.JumpPower

	humanoid.StateChanged:connect(function(old, new)
		if new == Enum.HumanoidStateType.Landed then
			canDoubleJump = false
			hasDoubleJumped = false
			humanoid.JumpPower = oldPower
		elseif new == Enum.HumanoidStateType.Freefall then
			wait(TIME_BETWEEN_JUMPS)
			canDoubleJump = true
		end
	end)
end

if localPlayer.Character then
	characterAdded(localPlayer.Character)
end



local function hb(size, cframe, ignore, char)
	local hb = Instance.new("Part", workspace.Fx)
	hb.Anchored = true
	hb.CanCollide = false
	hb.Transparency = 0.6
	hb.Name = "hb"
	hb.Material = Enum.Material.ForceField
	hb.CanQuery = false
	hb.Size = size
	hb.CFrame = cframe
	
	local con
	con = hb.Touched:Connect(function()
		con:Disconnect()
	end)
	
	local lasttarg
	
	for i,v in pairs(hb:GetTouchingParts()) do
		if v.Parent:FindFirstChild("Humanoid") and table.find(ignore, v.Parent) == nil then
			if lasttarg then
				if (lasttarg.Position - char.PrimaryPart.Position).Magnitude > (v.Position - char.PrimaryPart.Position).Magnitude then
					lasttarg = v.Parent.PrimaryPart
				end
			else
				lasttarg = v.Parent.PrimaryPart
			end
		end
	end
	
	hb:Destroy()
	if lasttarg then
		return lasttarg.Parent
	else
		return nil
	end
end

local function crater(data)
	local currentTime = tick()
	local craterRaycastResult
	repeat
		craterRaycastResult = workspace:Raycast(data.Target.PrimaryPart.Position, data.Direction, params)
		print(craterRaycastResult)
		wait()
	until tick() - currentTime > 5 or craterRaycastResult ~= nil 
	if craterRaycastResult then
		for i = 0, data.Count do
			local part = Instance.new("Part", workspace.Fx)
			part.BottomSurface = part.LeftSurface
			part.TopSurface = part.LeftSurface
			part.Size = Vector3.new(4, math.random(10,20)/10, math.random(10,20)/10)
			part.Anchored = true
			part.CFrame = CFrame.new(craterRaycastResult.Position, craterRaycastResult.Position +craterRaycastResult.Normal)
			part.CFrame = part.CFrame * CFrame.Angles(math.rad(90), math.rad(i * 360/data.Count), 0) * CFrame.new(0,0,data.Size*-2) * CFrame.Angles(math.rad(35),0,0)
			part.CanQuery = false
			part.CanCollide = false
			part.CanTouch = false
			
			local result = workspace:Raycast(part.Position + craterRaycastResult.Normal * 4, craterRaycastResult.Normal * -10, params)
			if result then
				part.Position = result.Position
				part.Material = result.Material
				part.Color = result.Instance.Color
			else
				part:Destroy()
			end
			
			part.Position = part.Position + craterRaycastResult.Normal * -4
			ts:Create(part, TweenInfo.new(0.2, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out, 0, false, 0), {Position = part.Position + craterRaycastResult.Normal * 4}):Play()
			
			spawn(function()
				game.Debris:AddItem(part, 4)
				wait(3)
				ts:Create(part, TweenInfo.new(0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out, 0, false, 0), {Position = part.Position + craterRaycastResult.Normal * -4}):Play()
			end)
			
			
			
			if i % 3 < 2 and result then
				local rubble = part:Clone()
				rubble.Size = Vector3.new(math.random(20,40)/20, math.random(20,40)/20, math.random(20,40)/20)
				rubble.Position = result.Position + craterRaycastResult.Normal * 4
				rubble.Material = result.Material
				rubble.Color = result.Instance.Color
				
				rubble.Parent = workspace.Fx
				rubble.Anchored = false
				rubble.CanCollide = true
				
				local bv = Instance.new("BodyVelocity", rubble)
				bv.Velocity = Vector3.new(math.random(-40,40), 30, math.random(-40,40))
				bv.MaxForce = Vector3.new(99999,99999,99999)
				bv.Name = "Velocity"
				
				game.Debris:AddItem(bv, 1)
				game.Debris:AddItem(rubble, 4)
				
				spawn(function()
					wait(2)
					
					ts:Create(rubble, TweenInfo.new(1, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out, 0, false, 0), {Transparency = 1}):Play()
				end)
				
				rubble.Transparency = 0
			end
		end
		
		-- shockwave--
		
		
		
	end
end

local function finisher(data)
	local cf = data.Character.PrimaryPart.CFrame
	for i = 1,40 do
		local rock = Instance.new("Part")
		rock.Size = Vector3.new(math.random(10,20)/10,math.random(10,20)/10,math.random(10,20)/10)
		rock.CFrame = cf * CFrame.new(3,0,-4 + (i * -1))
		rock.CanCollide = false
		rock.Anchored = true
		local result = workspace:Raycast(rock.Position, Vector3.new(0, -4, 0), params)
		if result then
			rock.Position = result.Position+Vector3.new(0,0.25,0)
			rock.Material = result.Material
			rock.Color = result.Instance.Color
			rock.Rotation = Vector3.new(math.random(0,180), math.random(0,180), math.random(0,180))
			rock.Parent = workspace.Fx
			game.Debris:AddItem(rock, 2)
		else
			rock:Destroy()
		end
		
		local rock = Instance.new("Part")
		rock.Size = Vector3.new(math.random(10,20)/10,math.random(10,20)/10,math.random(10,20)/10)
		rock.CFrame = cf * CFrame.new(-3,0,-4 + (i * -1))
		rock.Anchored = true
		local result = workspace:Raycast(rock.Position, Vector3.new(0,-4,0), params)
		if result then
			rock.Position = result.Position+Vector3.new(0,0.25,0)
			rock.Material = result.Material
			rock.Color = result.Instance.Color
			
			rock.Rotation = Vector3.new(math.random(0,180), math.random(0,180), math.random(0,180))
			rock.Parent = workspace.Fx
			game.Debris:AddItem(rock,2)
		else
			rock:Destroy()
		
		end
		
		
		if i == 40 then
			for n = 1,4 do
				local rock = Instance.new("Part")
				rock.Size = Vector3.new(math.random(10,20)/10,math.random(10,20)/10,math.random(10,20)/10)
				rock.CFrame = cf * CFrame.new(3 - (n/1.5), 0, -45 + (n * -0.5))
				rock.CanCollide = false
				rock.Anchored = true
				local result = workspace:Raycast(rock.Position, Vector3.new(0,-4,0), params)
				if result then
					rock.Position = result.Position+Vector3.new(0,0.25,0)
					rock.Material = result.Material
					rock.Color = result.Instance.Color
					
					rock.Rotation = Vector3.new(math.random(0,180), math.random(0,180), math.random(0,180))
					rock.Parent = workspace.Fx
					game.Debris:AddItem(rock, 2)
				else
					rock:Destroy()
				end
				
				local rock = Instance.new("Part")
				rock.Size = Vector3.new(math.random(10,20)/10,math.random(10,20)/10,math.random(10,20)/10)
				rock.CFrame = cf * CFrame.new(-3 + (n/2), 0, -45 + (n * -0.5))
				rock.CanCollide = false
				rock.Anchored = true
				local result = workspace:Raycast(rock.Position, Vector3.new(0,-4,0), params)
				if result then
					rock.Position = result.Position+Vector3.new(0,0.25,0)
					rock.Material = result.Material
					rock.Color = result.Instance.Color

					rock.Rotation = Vector3.new(math.random(0,180), math.random(0,180), math.random(0,180))
					rock.Parent = workspace.Fx
					game.Debris:AddItem(rock, 2)
				else
					rock:Destroy()
				end
			end
		end
		if i % 6 == 0 then
			wait()
		end
	end
end

uis.InputBegan:Connect(function(input, gpe)
	print(input.UserInputType)
	local playergui = game.Players.LocalPlayer.PlayerGui
	
	if gpe then return end
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		if playergui.ToolsGui:FindFirstChild("Center"):FindFirstChild("Weapon") or #playergui.ToolsGui.Center:FindFirstChildOfClass("ViewportFrame"):GetChildren() == 0 then
			if tick() - LastTimeM1 >0.3 and tick() - LastM1End >0.7 and not blocking and statusFolder:FindFirstChild("Stun") == nil then
				if tick() - LastTimeM1 > 0.7 then
					combo = 1
					canAir = true
					canDoubleJump = true
				end

				LastTimeM1 = tick()

				local animation = Instance.new("Animation", workspace.Fx)
				local air = nil

				local animfolder
				local weapon
				for i,v in pairs(game.Players.LocalPlayer.EquippedItems:GetChildren()) do
					for l,m in pairs(game.ReplicatedStorage.Items:GetChildren()) do
						if m:FindFirstChild(v.Name) then
							if m:FindFirstChild(v.Name).Info:FindFirstChild("Type").Value == "Weapon" then

								if playergui.ToolsGui.Center:FindFirstChildOfClass("ViewportFrame"):FindFirstChild(v.Name) then
									weapon = v.Name
								end

							end
						end
					end
				end
				if weapon ~= nil then
					animfolder = game.ReplicatedStorage.Animations:FindFirstChild(weapon)
				else
					animfolder = game.ReplicatedStorage.Animations.HandCombat
				end

				if uis:IsKeyDown("Space") and combo == 4 and canAir == true then
					canAir = false
					animation.AnimationId = animfolder:FindFirstChild("AirAnims"):FindFirstChild("1").AnimationId
					air = "Up"
				elseif not uis:IsKeyDown("Space") and combo == 5 and canAir == false then
					animation.AnimationId = animfolder:FindFirstChild("AirAnims"):FindFirstChild("2").AnimationId
					air = "Down"
				else

					animation.AnimationId = animfolder:FindFirstChild("PunchAnims"):FindFirstChild(combo).AnimationId

				end

				local load = humanoid:LoadAnimation(animation)
				load:Play()

				animation:Destroy()



				local hb = Instance.new("Part", workspace.Fx)
				hb.Anchored = true
				hb.CanCollide = false
				hb.Transparency = 0.6
				hb.Name = "hb"
				hb.Material = Enum.Material.ForceField
				hb.CanQuery = false
				hb.Size = animfolder:FindFirstChild("Info"):FindFirstChild("HitBoxSize").Value
				hb.CFrame = character.PrimaryPart.CFrame*CFrame.new(0,-6,-3)

				local con
				con = hb.Touched:Connect(function()
					con:Disconnect()
				end)

				for i,v in pairs(hb:GetTouchingParts()) do
					if v.Parent:FindFirstChild("Humanoid") and table.find({character}, v.Parent) == nil then
						if v == v.Parent.PrimaryPart and v.Parent.Humanoid.Health > 0 then

							local inparty = isinparty(game.Players.LocalPlayer.Name, v.Parent.Name)
							if not inparty then
								local data = {
									["Target"] = v.Parent,
									["Character"] = character,
									["Combo"] = combo,
									["Air"] = air,
									["Action"] = "m1",
								}

								remote:FireServer(data)
								print("Yo we gotta hit", combo, air, v.Parent.Humanoid.Health)

								local attacking = Instance.new("IntValue", character.StatusFolder)
								attacking.Name = "Attacking"
								game.Debris:AddItem(attacking,0.4)
							end
						end

					end
				end

				hb:Destroy()



				if combo == #punchAnims then
					combo = 1
					LastM1End = tick()
				else
					combo += 1
					canDoubleJump = false

				end
				humanoid.WalkSpeed = 0
				wait(0.4)
				humanoid.WalkSpeed = 16

			end
				
		elseif #playergui.ToolsGui.Center:FindFirstChildOfClass("ViewportFrame"):GetChildren() >= 1 then
			
			game.ReplicatedStorage.Interact:FireServer(playergui.ToolsGui.Center:FindFirstChildOfClass("ViewportFrame"):GetChildren()[1].Name)
			print("fired")
			
			
			
		end
	elseif input.KeyCode == Enum.KeyCode.F and tick() - LastTimeM1 > 0.3 and statusFolder:FindFirstChild("Stun") == nil then
		print("fff")
		blocking = true
		local animation = Instance.new("Animation", workspace.Fx)
		animation.AnimationId = blockAnims[1]
		local blockanimation = humanoid.Animator:LoadAnimation(animation)
		blockanimation:Play()
		animation:Destroy()

		local data = {

			["Action"] = "Block",
			["Character"] = character

		}

		remote:FireServer(data)
		repeat
			wait()
		until blocking == false or statusFolder:FindFirstChild("Stun")
		blocking = false
		blockanimation:Stop()
	elseif input.KeyCode == Enum.KeyCode.E and statusFolder:FindFirstChild("Stun") == nil then
		local hitTarg = hb(Vector3.new(4,6,4), character.PrimaryPart.CFrame * CFrame.new(0,0,-3), {character}, character)

		if hitTarg then
			local data = {

				["Action"] = "Grip",
				["Character"] = character,
				["Target"] = hitTarg

			}

			remote:FireServer(data)

		end
	end
	
	
	
end)

uis.InputEnded:Connect(function(input, gpe)
	if input.KeyCode == Enum.KeyCode.F and blocking then
		blocking = not blocking
		local data = {
			
			["Action"] = "Unblock",
			["Character"] = character
			
		}
		
		remote:FireServer(data)
	end
end)

remote.OnClientEvent:Connect(function(data)
	if data.Action == "Crater" then
		crater(data)
	elseif data.Action == "Finisher" then
		finisher(data)
	elseif data.Action == "Block" then
	end
end)

statusFolder.ChildAdded:Connect(function(Child)
	local WalkSpeed = 16
	local JumpHeight = 7.2
	
	character.PrimaryPart.Anchored = false
	
	for i,status in pairs(statusFolder:GetChildren()) do
		if status.Name == "Stun" then
			WalkSpeed = 0
			JumpHeight = 0
		elseif status.Name == "Block" then
			WalkSpeed = 3
			JumpHeight = 3.6
		end
	end
	
	humanoid.WalkSpeed = WalkSpeed
	humanoid.JumpHeight = JumpHeight
end)

statusFolder.ChildRemoved:Connect(function(Child)
	local WalkSpeed = 16
	local JumpHeight = 7.2
	
	character.PrimaryPart.Anchored = false

	if blocking then
		WalkSpeed = 0
		JumpHeight = 0
	end

	for i,status in pairs(statusFolder:GetChildren()) do
		if status.Name == "Stun" then
			WalkSpeed = 0
			JumpHeight = 0
		elseif status.Name == "Block" then
			WalkSpeed = 3
			JumpHeight = 3.6
		end
	end
	humanoid.WalkSpeed = WalkSpeed
	humanoid.JumpHeight = JumpHeight
end)

humanoid.StateChanged:Connect(function(old, new)
	if new == Enum.HumanoidStateType.Landed then
		canAir = true
	end
end)

uis.JumpRequest:Connect(function()
	if tick() - LastTimeM1 < 1 then
		humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
	else
		humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
	end
end)

localPlayer.CharacterAdded:connect(characterAdded)
UserInputService.JumpRequest:connect(onJumpRequest)

sorry its so messy, I plan on cleaning it up

Try testing the event in another game place. If it still fires twice in another game, then most likely it’s a backend problem.

thats easier said than done, but ill try right now

1 Like

It doesn’t matter, the point here is we are trying to find the root of your problem.

Here’s a quick code review before I try and find the root cause of this problem:

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character.Humanoid

local statusFolder = character:WaitForChild("StatusFolder")

local uis = game:GetService("UserInputService")
local ts = game:GetService("TweenService")

local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Whitelist
params.FilterDescendantsInstances = {workspace.Map}

local remote = game.ReplicatedStorage.CombatEvent

local LastTimeM1 = 0
local LastM1End = 0
local combo = 1

local blocking = false
local canAir = true

local punchAnims = {
	
	"rbxassetid://11967384879",
	"rbxassetid://11965741396",
	"rbxassetid://11968253783",
	"rbxassetid://11978496178",
	"rbxassetid://11978551893",
	
}

local blockAnims = {
	
	"rbxassetid://11991966762"
	
}

local airAnims = {
	
	"rbxassetid://11968348350",
	"rbxassetid://11969785324"
}

local UserInputService = game:GetService("UserInputService")
local localPlayer = game.Players.LocalPlayer

local canDoubleJump = false
local hasDoubleJumped = false
local oldPower
local TIME_BETWEEN_JUMPS = 0.2
local DOUBLE_JUMP_POWER_MULTIPLIER = 1.4

function onJumpRequest()
	if not character or not humanoid or not character:IsDescendantOf(workspace) or
		humanoid:GetState() == Enum.HumanoidStateType.Dead then
		return
	end

	if canDoubleJump and not hasDoubleJumped then
		hasDoubleJumped = true
		humanoid.JumpPower = oldPower * DOUBLE_JUMP_POWER_MULTIPLIER
		humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
	end
end

local function isinparty(plr, hit)
	for i,v in pairs(game.Players:GetChildren()) do
		if v:FindFirstChild("Party") then
			if v:FindFirstChild("Party"):FindFirstChild(plr) and v:FindFirstChild("Party"):FindFirstChild(hit) then
				return true
			end
		end
	end
end

local function characterAdded(newCharacter)
	character = newCharacter
	humanoid = newCharacter:WaitForChild("Humanoid")
	hasDoubleJumped = false
	canDoubleJump = false
	oldPower = humanoid.JumpPower

	humanoid.StateChanged:connect(function(old, new)
		if new == Enum.HumanoidStateType.Landed then
			canDoubleJump = false
			hasDoubleJumped = false
			humanoid.JumpPower = oldPower
		elseif new == Enum.HumanoidStateType.Freefall then
			task.wait(TIME_BETWEEN_JUMPS)
			canDoubleJump = true
		end
	end)
end

if localPlayer.Character then
	characterAdded(localPlayer.Character)
end



local function hb(size, cframe, ignore, char)
	local hb = Instance.new("Part", workspace.Fx)
	hb.Anchored = true
	hb.CanCollide = false
	hb.Transparency = 0.6
	hb.Name = "hb"
	hb.Material = Enum.Material.ForceField
	hb.CanQuery = false
	hb.Size = size
	hb.CFrame = cframe
	
	local con
	con = hb.Touched:Connect(function()
		con:Disconnect()
	end)
	
	local lasttarg
	
	for i,v in pairs(hb:GetTouchingParts()) do
		if v.Parent:FindFirstChild("Humanoid") and table.find(ignore, v.Parent) == nil then
			if lasttarg then
				if (lasttarg.Position - char.PrimaryPart.Position).Magnitude > (v.Position - char.PrimaryPart.Position).Magnitude then
					lasttarg = v.Parent.PrimaryPart
				end
			else
				lasttarg = v.Parent.PrimaryPart
			end
		end
	end
	
	hb:Destroy()
	if lasttarg then
		return lasttarg.Parent
	else
		return nil
	end
end

local function crater(data)
	local currentTime = tick()
	local craterRaycastResult
	repeat
		craterRaycastResult = workspace:Raycast(data.Target.PrimaryPart.Position, data.Direction, params)
		print(craterRaycastResult)
		wait()
	until tick() - currentTime > 5 or craterRaycastResult ~= nil 
	if craterRaycastResult then
		for i = 0, data.Count do
			local part = Instance.new("Part", workspace.Fx)
			part.BottomSurface = part.LeftSurface
			part.TopSurface = part.LeftSurface
			part.Size = Vector3.new(4, math.random(10,20)/10, math.random(10,20)/10)
			part.Anchored = true
			part.CFrame = CFrame.new(craterRaycastResult.Position, craterRaycastResult.Position +craterRaycastResult.Normal)
			part.CFrame = part.CFrame * CFrame.Angles(math.rad(90), math.rad(i * 360/data.Count), 0) * CFrame.new(0,0,data.Size*-2) * CFrame.Angles(math.rad(35),0,0)
			part.CanQuery = false
			part.CanCollide = false
			part.CanTouch = false
			
			local result = workspace:Raycast(part.Position + craterRaycastResult.Normal * 4, craterRaycastResult.Normal * -10, params)
			if result then
				part.Position = result.Position
				part.Material = result.Material
				part.Color = result.Instance.Color
			else
				part:Destroy()
			end
			
			part.Position = part.Position + craterRaycastResult.Normal * -4
			ts:Create(part, TweenInfo.new(0.2, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out, 0, false, 0), {Position = part.Position + craterRaycastResult.Normal * 4}):Play()
			
			spawn(function()
				game.Debris:AddItem(part, 4)
				wait(3)
				ts:Create(part, TweenInfo.new(0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out, 0, false, 0), {Position = part.Position + craterRaycastResult.Normal * -4}):Play()
			end)
			
			
			
			if i % 3 < 2 and result then
				local rubble = part:Clone()
				rubble.Size = Vector3.new(math.random(20,40)/20, math.random(20,40)/20, math.random(20,40)/20)
				rubble.Position = result.Position + craterRaycastResult.Normal * 4
				rubble.Material = result.Material
				rubble.Color = result.Instance.Color
				
				rubble.Parent = workspace.Fx
				rubble.Anchored = false
				rubble.CanCollide = true
				
				local bv = Instance.new("BodyVelocity", rubble)
				bv.Velocity = Vector3.new(math.random(-40,40), 30, math.random(-40,40))
				bv.MaxForce = Vector3.new(99999,99999,99999)
				bv.Name = "Velocity"
				
				game.Debris:AddItem(bv, 1)
				game.Debris:AddItem(rubble, 4)
				
				task.spawn(function()
					task.wait(2)
					
					ts:Create(rubble, TweenInfo.new(1, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out, 0, false, 0), {Transparency = 1}):Play()
				end)
				
				rubble.Transparency = 0
			end
		end
		
		-- shockwave--
		
		
		
	end
end

local function finisher(data)
	local cf = data.Character.PrimaryPart.CFrame
	for i = 1,40 do
		local rock = Instance.new("Part")
		rock.Size = Vector3.new(math.random(10,20)/10,math.random(10,20)/10,math.random(10,20)/10)
		rock.CFrame = cf * CFrame.new(3,0,-4 + (i * -1))
		rock.CanCollide = false
		rock.Anchored = true
		local result = workspace:Raycast(rock.Position, Vector3.new(0, -4, 0), params)
		if result then
			rock.Position = result.Position+Vector3.new(0,0.25,0)
			rock.Material = result.Material
			rock.Color = result.Instance.Color
			rock.Rotation = Vector3.new(math.random(0,180), math.random(0,180), math.random(0,180))
			rock.Parent = workspace.Fx
			game.Debris:AddItem(rock, 2)
		else
			rock:Destroy()
		end
		
		local rock = Instance.new("Part")
		rock.Size = Vector3.new(math.random(10,20)/10,math.random(10,20)/10,math.random(10,20)/10)
		rock.CFrame = cf * CFrame.new(-3,0,-4 + (i * -1))
		rock.Anchored = true
		local result = workspace:Raycast(rock.Position, Vector3.new(0,-4,0), params)
		if result then
			rock.Position = result.Position+Vector3.new(0,0.25,0)
			rock.Material = result.Material
			rock.Color = result.Instance.Color
			
			rock.Rotation = Vector3.new(math.random(0,180), math.random(0,180), math.random(0,180))
			rock.Parent = workspace.Fx
			game.Debris:AddItem(rock,2)
		else
			rock:Destroy()
		
		end
		
		
		if i == 40 then
			for n = 1,4 do
				local rock = Instance.new("Part")
				rock.Size = Vector3.new(math.random(10,20)/10,math.random(10,20)/10,math.random(10,20)/10)
				rock.CFrame = cf * CFrame.new(3 - (n/1.5), 0, -45 + (n * -0.5))
				rock.CanCollide = false
				rock.Anchored = true
				local result = workspace:Raycast(rock.Position, Vector3.new(0,-4,0), params)
				if result then
					rock.Position = result.Position+Vector3.new(0,0.25,0)
					rock.Material = result.Material
					rock.Color = result.Instance.Color
					
					rock.Rotation = Vector3.new(math.random(0,180), math.random(0,180), math.random(0,180))
					rock.Parent = workspace.Fx
					game.Debris:AddItem(rock, 2)
				else
					rock:Destroy()
				end
				
				local rock = Instance.new("Part")
				rock.Size = Vector3.new(math.random(10,20)/10,math.random(10,20)/10,math.random(10,20)/10)
				rock.CFrame = cf * CFrame.new(-3 + (n/2), 0, -45 + (n * -0.5))
				rock.CanCollide = false
				rock.Anchored = true
				local result = workspace:Raycast(rock.Position, Vector3.new(0,-4,0), params)
				if result then
					rock.Position = result.Position+Vector3.new(0,0.25,0)
					rock.Material = result.Material
					rock.Color = result.Instance.Color

					rock.Rotation = Vector3.new(math.random(0,180), math.random(0,180), math.random(0,180))
					rock.Parent = workspace.Fx
					game.Debris:AddItem(rock, 2)
				else
					rock:Destroy()
				end
			end
		end
		if i % 6 == 0 then
			wait()
		end
	end
end

uis.InputBegan:Connect(function(input, gpe)
	print(input.UserInputType)
	local playergui = game.Players.LocalPlayer.PlayerGui
	
	if gpe then return end
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		if playergui.ToolsGui:FindFirstChild("Center"):FindFirstChild("Weapon") or #playergui.ToolsGui.Center:FindFirstChildOfClass("ViewportFrame"):GetChildren() == 0 then
			if tick() - LastTimeM1 >0.3 and tick() - LastM1End >0.7 and not blocking and statusFolder:FindFirstChild("Stun") == nil then
				if tick() - LastTimeM1 > 0.7 then
					combo = 1
					canAir = true
					canDoubleJump = true
				end

				LastTimeM1 = tick()

				local animation = Instance.new("Animation", workspace.Fx)
				local air = nil

				local animfolder
				local weapon
				for _,v in pairs(game.Players.LocalPlayer.EquippedItems:GetChildren()) do
					for _,m in pairs(game.ReplicatedStorage.Items:GetChildren()) do
						if m:FindFirstChild(v.Name) then
							if m:FindFirstChild(v.Name).Info:FindFirstChild("Type").Value == "Weapon" then

								if playergui.ToolsGui.Center:FindFirstChildOfClass("ViewportFrame"):FindFirstChild(v.Name) then
									weapon = v.Name
								end

							end
						end
					end
				end
				if weapon ~= nil then
					animfolder = game.ReplicatedStorage.Animations:FindFirstChild(weapon)
				else
					animfolder = game.ReplicatedStorage.Animations.HandCombat
				end

				if uis:IsKeyDown("Space") and combo == 4 and canAir == true then
					canAir = false
					animation.AnimationId = animfolder:FindFirstChild("AirAnims"):FindFirstChild("1").AnimationId
					air = "Up"
				elseif not uis:IsKeyDown("Space") and combo == 5 and canAir == false then
					animation.AnimationId = animfolder:FindFirstChild("AirAnims"):FindFirstChild("2").AnimationId
					air = "Down"
				else

					animation.AnimationId = animfolder:FindFirstChild("PunchAnims"):FindFirstChild(combo).AnimationId

				end

				local load = humanoid:LoadAnimation(animation)
				load:Play()

				animation:Destroy()



				local hb = Instance.new("Part", workspace.Fx)
				hb.Anchored = true
				hb.CanCollide = false
				hb.Transparency = 0.6
				hb.Name = "hb"
				hb.Material = Enum.Material.ForceField
				hb.CanQuery = false
				hb.Size = animfolder:FindFirstChild("Info"):FindFirstChild("HitBoxSize").Value
				hb.CFrame = character.PrimaryPart.CFrame*CFrame.new(0,-6,-3)

				local con
				con = hb.Touched:Connect(function()
					con:Disconnect()
				end)

				for i,v in pairs(hb:GetTouchingParts()) do
					if v.Parent:FindFirstChild("Humanoid") and table.find({character}, v.Parent) == nil then
						if v == v.Parent.PrimaryPart and v.Parent.Humanoid.Health > 0 then

							local inparty = isinparty(game.Players.LocalPlayer.Name, v.Parent.Name)
							if not inparty then
								local data = {
									["Target"] = v.Parent,
									["Character"] = character,
									["Combo"] = combo,
									["Air"] = air,
									["Action"] = "m1",
								}

								remote:FireServer(data)
								print("Yo we gotta hit", combo, air, v.Parent.Humanoid.Health)

								local attacking = Instance.new("IntValue", character.StatusFolder)
								attacking.Name = "Attacking"
								game.Debris:AddItem(attacking,0.4)
							end
						end

					end
				end

				hb:Destroy()

				if combo == #punchAnims then
					combo = 1
					LastM1End = tick()
				else
					combo += 1
					canDoubleJump = false

				end
				humanoid.WalkSpeed = 0
				task.wait(0.4)
				humanoid.WalkSpeed = 16

			end
				
		elseif #playergui.ToolsGui.Center:FindFirstChildOfClass("ViewportFrame"):GetChildren() >= 1 then
			
			game.ReplicatedStorage.Interact:FireServer(playergui.ToolsGui.Center:FindFirstChildOfClass("ViewportFrame"):GetChildren()[1].Name)
			print("fired")
			
			
			
		end
	elseif input.KeyCode == Enum.KeyCode.F and tick() - LastTimeM1 > 0.3 and statusFolder:FindFirstChild("Stun") == nil then
		print("fff")
		blocking = true
		local animation = Instance.new("Animation", workspace.Fx)
		animation.AnimationId = blockAnims[1]
		local blockanimation = humanoid.Animator:LoadAnimation(animation)
		blockanimation:Play()
		animation:Destroy()

		local data = {

			["Action"] = "Block",
			["Character"] = character

		}

		remote:FireServer(data)
		repeat
			task.wait()
		until blocking == false or statusFolder:FindFirstChild("Stun")
		blocking = false
		blockanimation:Stop()
	elseif input.KeyCode == Enum.KeyCode.E and statusFolder:FindFirstChild("Stun") == nil then
		local hitTarg = hb(Vector3.new(4,6,4), character.PrimaryPart.CFrame * CFrame.new(0,0,-3), {character}, character)

		if hitTarg then
			local data = {

				["Action"] = "Grip",
				["Character"] = character,
				["Target"] = hitTarg

			}

			remote:FireServer(data)

		end
	end
	
	
	
end)

uis.InputEnded:Connect(function(input, gpe)
    if gpe then return end

	if input.KeyCode == Enum.KeyCode.F and blocking then
		blocking = not blocking
		local data = {
			
			["Action"] = "Unblock",
			["Character"] = character
			
		}
		
		remote:FireServer(data)
	end
end)

remote.OnClientEvent:Connect(function(data)
	if data.Action == "Crater" then
		crater(data)
	elseif data.Action == "Finisher" then
		finisher(data)
	elseif data.Action == "Block" then
	end
end)

statusFolder.ChildAdded:Connect(function()
	local WalkSpeed = 16
	local JumpHeight = 7.2
	
	character.PrimaryPart.Anchored = false
	
	for _,status in pairs(statusFolder:GetChildren()) do
		if status.Name == "Stun" then
			WalkSpeed = 0
			JumpHeight = 0
		elseif status.Name == "Block" then
			WalkSpeed = 3
			JumpHeight = 3.6
		end
	end
	
	humanoid.WalkSpeed = WalkSpeed
	humanoid.JumpHeight = JumpHeight
end)

statusFolder.ChildRemoved:Connect(function()
	local WalkSpeed = 16
	local JumpHeight = 7.2
	
	character.PrimaryPart.Anchored = false

	if blocking then
		WalkSpeed = 0
		JumpHeight = 0
	end

	for i,status in pairs(statusFolder:GetChildren()) do
		if status.Name == "Stun" then
			WalkSpeed = 0
			JumpHeight = 0
		elseif status.Name == "Block" then
			WalkSpeed = 3
			JumpHeight = 3.6
		end
	end
	humanoid.WalkSpeed = WalkSpeed
	humanoid.JumpHeight = JumpHeight
end)

humanoid.StateChanged:Connect(function(_, new)
	if new == Enum.HumanoidStateType.Landed then
		canAir = true
	end
end)

uis.JumpRequest:Connect(function()
	if tick() - LastTimeM1 < 1 then
		humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
	else
		humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
	end
end)

localPlayer.CharacterAdded:Connect(characterAdded)
UserInputService.JumpRequest:Connect(onJumpRequest)

Ok it tried making a fresh game and copying the script over and its still having the same issue.

Try running a new script that only contains these lines:

UserInputService.InputBegan(function()
    print("test")
end)

I disabled both scripts that used UserInputService.InputBegan and copied what you said and no change it still prints twice.

This might be a studio issue. Try restarting it, if that fails reinstall studio.

I thought of that already so I tried restarting it and still no change, but I made a new baseplate and put just what you told me to put and it was only printing once. so the Issue has to be with the script but ive looked through the script probably 20 times and cannot find what is wrong.

1 Like

Can you show us the script again? Make sure only one script runs the event and not two scripts so we can narrow down the problem much easier.

In the fresh baseplate that I created I made a script that used input began and the issue was gone, but then i duplicated the script and the issue came back. but when I removed the second(on the original) it didnt fix the issue, so it tried on the new baseplate again and it lets me have both while only running once. this makes absolutely no sense.