Keybind is not firing my RemoteEvent ( Handcuff System )

hey, im trying to make a handcuff system with keybinds, everything works fine, if i put any other code not related to RemoteEvents it works perfectly, it doesnt even print when the other keybinds are pressed, I’ve tried many ways to fix this but it still doesnt work

Localscript:

popupEvent.OnClientEvent:Connect(function(target, action)
	if target == nil or action == nil then return end

	if action == "create" then
		local popup = game.ReplicatedStorage.HandcuffPopup:Clone()
		popup.Parent = target.Character.HumanoidRootPart
		popup.Adornee = target.Character.HumanoidRootPart
		popup.Popup.pUser.Text = target.Name

		local actions = UIS.InputBegan:Connect(function(input, gameProcessed)
			if not gameProcessed then 
				ActionsEvent:FireServer(input, target, xd[1])
			end
		end)

		task.spawn(function() 
			while wait(.1) do
				if popup == nil or target == nil or target.Character == nil or target.Character.Humanoid.Health == 0 then
					actions:Disconnect()
					break
				end
			end
		end)
	elseif action == "delete" then
		if target.Character.HumanoidRootPart:FindFirstChild("HandcuffPopup") then
			target.Character.HumanoidRootPart.HandcuffPopup:Destroy()
		end
	end
end)

ServerScript:

local actionCooldown = false

ActionsEvent.OnServerEvent:Connect(function(player, action, target, key)
	if player == nil or player.Character == nil or player.Character.Humanoid.Health == 0 or action == nil or target == nil or typeof(key) ~= "string" or player.Name ~= config.owner or key ~= playerKey then return end

	if action.KeyCode == Enum.KeyCode.E then
		if actionCooldown == false then
			actionCooldown = true

			print("arrest")

			wait(.15)
			actionCooldown = false
		end
	elseif action.KeyCode == Enum.KeyCode.F then
		if actionCooldown == false then
			actionCooldown = true

			local dist = (player.Character.Head.Position - target.Character.Head.Position).Magnitude

			if dist <= (script.Parent.HandcuffPopup.MaxDistance/1.5) then
				target.Character.Humanoid.WalkSpeed = 16
				target.Character.Humanoid.JumpPower = 50

				for _, a in pairs(target.Character.Humanoid:GetPlayingAnimationTracks()) do
					a:Stop()
				end

				script.Parent.Popup:FireClient(player, target, "delete")
			end

			wait(.15)
			actionCooldown = false
		end
	elseif action.KeyCode == Enum.KeyCode.Q then
		if actionCooldown == false then
			actionCooldown = true

			print("search")

			wait(.15)
			actionCooldown = false
		end
	end
end)
2 Likes

where/how does this event get called? How many parameters are you passing in?

2 Likes

its called on the server, when the tool is activated it fires a RemoteEvent

if player.Name == config.owner and key == playerKey then
			if option == "equipped" then
				if player.Character:FindFirstChild(script.Parent.Name) then
					config.equipped = true
				else
					config.equipped = false
				end
			elseif option == "activated" then

				local difftime = (os.clock() - config.activated.Time)
				local minTime = 0.125

				if difftime >= minTime and config.activated.Bool == false then
					config.activated.Bool = true

					local touched = false

					local anim = player.Character.Humanoid:LoadAnimation(script.Parent.CuffAnim)
					anim:Play()

					local touchFunc = script.Parent.Hitbox.Touched:Connect(function(hit)
						if hit:IsA("BasePart") and hit.Parent:FindFirstChildWhichIsA("Humanoid") and touched == false then
							local targetCharacter = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
							if targetCharacter ~= player and not targetCharacter.Character:FindFirstChild("CuffOfficer") then
								touched = true

								targetCharacter.Character.Humanoid.WalkSpeed = 0
								targetCharacter.Character.Humanoid.JumpPower = 0

								local animm = targetCharacter.Character.Humanoid:LoadAnimation(script.Parent.CuffedAnim)
								animm:Play()

								local identifier = Instance.new("StringValue", targetCharacter.Character)
								identifier.Name = "CuffOfficer"
								identifier.Value = player.Name

								script.Parent.Popup:FireClient(player, targetCharacter, "create")
							end
						end
					end)	

					anim.Stopped:Connect(function()
						touchFunc:Disconnect()
						wait(minTime)
						config.activated.Time = os.clock()
						config.activated.Bool = false
						return
					end)
				end
1 Like

Ok, print(target, action) at the top of the Local Script, tell me what get’s outputted.

1 Like

already tried it, i tried doing print(target.Name, action) it will print the name of the suspect and the action is the input (will be used on the server to do input.KeyCode)

1 Like

i still didnt find a solution for this