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

this is a update repost, im sorry, but i rlly needs this to be fixed, and im actually dying by trying to figure this out
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, or when i change a character, 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 rlyl cant find whats wrong, everything works completely fine 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)
1 Like

is the localscript in starterplayerscripts?

if u mean where i put it, its in the starterpack, does it matter? should i put it in starterplayerscripts?

just to make things easier to read, i recommend you get rid of the function and replace the check with this:

if debounce then return end
debounce = true
delay(0.5, function() debounce = false end)

i mean those functions might be the ones who caused problems but in some points u got it too, i put it there just so people can actually see the whole script. but about the starterplayerscripts thing, so does it matter, dont want u to feel it in any hard ways tho, but since u mentioned it im trying to figure it out

it does, since you get a new character every time you respawn, making your character variable old, but since it isnt in starterplayerscripts, it should start fresh every time you respawn.

so starterpack is cool then? sorry for this much question im just trying to know it more

no worries, i recommend either startergui or startercharacterscripts if your going to make a local script that resets on respawn

1 Like

ong u saved my life, thank u soooo much :pray: :pray: :pray: :pray: :grin:

1 Like