UserInputService doesnt work after publish(UDT:Still Not Fixed)

so i made a script that makes player punches, it all works fine but when i publish it and get into the real game, it sometimes doesn’t work, around character dies for 3 times, it doesn’t fire the remote event anymore, i used a lot of prints to let me know wat’s the problem, but it didnt print anything including the “Fired” so i presume the problem is on this script
update:
i got different characters in the game so i use the line
if c:FindFirstChild("AceHair")then
to see which character it is, and i dont know if that’s causing the problem or not, i rll cant find whats wrong, everything works completely find in studio test modes, includes the local server mode, but in the published version it just doesnt work :weary: :weary: i worked so hard on this project and this is the actual last step for it to be complete or else it just gon to be a waste, so if anyone can help me i would rlly rlly rlly appreciate them

local player = game.Players.LocalPlayer
repeat wait() until player.Character
local c = player.Character
repeat wait() until c:FindFirstChild("Humanoid")
local mouse = player:GetMouse()
local ReplicatedStorage = game.ReplicatedStorage
local UserInputService = game:GetService("UserInputService")
local Debounce = false
local function punchCD()
	Debounce = true
	wait(0.5)
	Debounce = false
end

UserInputService.InputBegan:Connect(function(Input,IsTyping)
	if IsTyping then print("IsTyping") return end
	if Input.KeyCode == Enum.KeyCode['Space']then
		if c.Humanoid.Health ~= 0 then
			if c:FindFirstChild("Stunned") then return end
				if Debounce == true then print("SkillCoolingDown") return end
					if c:FindFirstChild("AceHair")then
						if c:FindFirstChild("UsingSkill")then return
						else
							ReplicatedStorage.AcePunch:FireServer()
							print("Fired")
							Debounce=true
							punchCD()
						end
					end
		end
		end		
end)

Try this one

UserInputService.InputBegan:Connect(function(Input,IsTyping)
	if not IsTyping then
		if Input.KeyCode == Enum.KeyCode['Space'] then
			if c:WaitForChild("Humanoid").Health ~= 0 then
				if not c:FindFirstChild("Stunned") then
					if not Debounce then
						if c:FindFirstChild("AceHair") then
							if c:FindFirstChild("UsingSkill") then
							else
								ReplicatedStorage.AcePunch:FireServer()
								print("Fired")
								Debounce=true
								punchCD()
							end
						end
					end
				end
			end
		end
	end
end)

The reason why it didn’t work was probably because of the return statements,atleast that’s something i have noticed.

sadly the bug still appears but thx for the advice tho

2 Likes

Can you send the ServerScript.

i can but im pretty sure the problem is with this script since it didnt even fire the event

Try this, possible it may work.

UserInputService.InputBegan:Connect(function(Input,IsTyping)
	if IsTyping then print("IsTyping") return end
	if Input.KeyCode == Enum.KeyCode['Space']then
		if c.Humanoid.Health ~= 0 then
			if c:FindFirstChild("Stunned") then return end
			if Debounce == true then print("SkillCoolingDown") return end
			if c:FindFirstChild("AceHair")then
				if not c:FindFirstChild("UsingSkill")then
					ReplicatedStorage.AcePunch:FireServer()
					print("Fired")
					Debounce=true
					punchCD()
				end
			end
		end
	end		
end)

UPDATE: at first it seems alright but then the problem appears again :dizzy_face: :dizzy_face:

like any roblox devs can explain this, im sorry, but im actually dying tryin to figure this out