Why is my event not firing?

This is my code, why is the event not firing?

UIP.InputBegan:Connect(function(Input, GPE)
	if GPE then return end
	if Input.KeyCode == Enum.KeyCode.E and Debounce == 1 and toolquip == true then
		print("Local Script Recieved Input . . .")
		Debounce = 2
		spawn(function()

		ic = true
		wait(0.41)
		ic = false
			
		end)
		track:Play()
		wait(0.15)
		track:AdjustSpeed(0)
        holdconnecting:FireServer(char)
		if (root.Position - mouse.Hit.Position).Magnitude >= 2 then
			while Debounce == 2 do
				wait()
				root.CFrame = CFrame.lookAt(root.Position,mouse.Hit.Position)
			end
		end
	end
end)
1 Like

Have you declared the variable containing the UserInputService?

1 Like

What is char here…? Is it a variable that is declared somewhere else in the code?

local tool = script.Parent
local UIP = game:GetService("UserInputService")
local Remote = tool:WaitForChild("RemoteEvent")
local player = game.Players.LocalPlayer

local char = player.Character
local root = char:WaitForChild("HumanoidRootPart")
local Debounce = 1
local anim = script.Animation

local track = char.Humanoid:LoadAnimation(anim)
local ic = script.InstaCast
local Tool = script.Parent
local toolquip = false
local hrp = char.HumanoidRootPart
local mouse = player:GetMouse()
local holdconnecting = tool:WaitForChild("HoldConnecting")

local function Equipped()
	print(". . . Detected Equip")
toolquip = true
end

local function UnEquipped()
    print(" . . . Detected Unequip")
toolquip = false
end

Tool.Equipped:Connect(Equipped)
Tool.Unequipped:Connect(UnEquipped)
UIP.InputBegan:Connect(function(Input, GPE)
	if GPE then return end
	if Input.KeyCode == Enum.KeyCode.E and Debounce == 1 and toolquip == true then
		print("Local Script Recieved Input . . .")
		Debounce = 2
		spawn(function()

		ic = true
		wait(0.41)
		ic = false
			
		end)
		track:Play()
		wait(0.15)
		track:AdjustSpeed(0)
        holdconnecting:FireServer(char)
		if (root.Position - mouse.Hit.Position).Magnitude >= 2 then
			while Debounce == 2 do
				wait()
				root.CFrame = CFrame.lookAt(root.Position,mouse.Hit.Position)
			end
		end
	end
end)

UIP.InputEnded:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.E and Debounce == 2 then
		repeat wait() until ic == false
		print(". . . Sending To Server")
		track:AdjustSpeed(1)
		Debounce = 3
		Remote:FireServer(char, player, UIP, tool)
		print(". . . SENT . . .")
		wait(4) -- cooldown
		Debounce = 1
	end
end)
local tool = script.Parent
local UIP = game:GetService("UserInputService")
local Remote = tool:WaitForChild("RemoteEvent")
local player = game.Players.LocalPlayer

local char = player.Character
local root = char:WaitForChild("HumanoidRootPart")
local Debounce = 1
local anim = script.Animation

local track = char.Humanoid:LoadAnimation(anim)
local ic = script.InstaCast
local Tool = script.Parent
local toolquip = false
local hrp = char.HumanoidRootPart
local mouse = player:GetMouse()
local holdconnecting = tool:WaitForChild("HoldConnecting")

local function Equipped()
	print(". . . Detected Equip")
toolquip = true
end

local function UnEquipped()
    print(" . . . Detected Unequip")
toolquip = false
end

Tool.Equipped:Connect(Equipped)
Tool.Unequipped:Connect(UnEquipped)
UIP.InputBegan:Connect(function(Input, GPE)
	if GPE then return end
	if Input.KeyCode == Enum.KeyCode.E and Debounce == 1 and toolquip == true then
		print("Local Script Recieved Input . . .")
		Debounce = 2
		spawn(function()

		ic = true
		wait(0.41)
		ic = false
			
		end)
		track:Play()
		wait(0.15)
		track:AdjustSpeed(0)
        holdconnecting:FireServer(char)
		if (root.Position - mouse.Hit.Position).Magnitude >= 2 then
			while Debounce == 2 do
				wait()
				root.CFrame = CFrame.lookAt(root.Position,mouse.Hit.Position)
			end
		end
	end
end)

UIP.InputEnded:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.E and Debounce == 2 then
		repeat wait() until ic == false
		print(". . . Sending To Server")
		track:AdjustSpeed(1)
		Debounce = 3
		Remote:FireServer(char, player, UIP, tool)
		print(". . . SENT . . .")
		wait(4) -- cooldown
		Debounce = 1
	end
end)

Make “GPE” be “not GPE” like this:

if not GPE then
   return
end

the script runs, and it works fine

would this fix the script? cause like, the whole script works it just doesn’t fire the event

Add debugs and im not sure why are you trying to send the player’s character to the remote.

local remote = script.Parent.Parent.RemoteEvent
local replicated =  game:GetService("ReplicatedStorage")
local module = game.ReplicatedStorage.module
local ragdoll = require(module.Ragdoll)
local hold = script.Parent.Parent:WaitForChild("HoldConnecting")
hold.OnServerEvent:Connect(function(Character)
	local RootPart = Character:WaitForChild("HumanoidRootPart")

 AlignPos = Instance.new("AlignPosition")
 AlignAttachment = Instance.new("Attachment")

	AlignAttachment.Parent = RootPart

	AlignPos.Parent = RootPart
	AlignPos.MaxForce = 10e38
	AlignPos.Responsiveness = 10e38
	AlignPos.Mode = Enum.PositionAlignmentMode.OneAttachment
	AlignPos.Attachment0 = AlignAttachment
	AlignPos.Position = RootPart.Position
end)

ah right. add breakpoints or prints to check where it doesnt run.

the local runs but the hold in the server script never fires

didn’t you say it doesn’t fire the event? well the only issue i see in the server script is align pos and align attachment dont have the “local” datatype, what i mean is you wrote “AlignPos” instead of “local AlignPos”.

tried that still didn’t fix? why is this not running?

also I said the hold never fires cause it isn’t the local runs but the hold function doesn’t

Isn’t this supposed to be if not GPE then return end? The variable GPE is false if the input has already been dealt with. You should only continue if it’s true. This code continues if it’s false!

If I do that it gives me a error, and the gpe works sooo

Try to add the player argument when ur calling .OnServerEvent like this;

hold.OnServerEvent:Connect(function(Player,Character)

and see if that helps, because the first argument of a remote even on the server is always player.

still not working :confused:

20 char lim

Do you get any errors in the console?