I'm trying to make it so that when the player holds down G while a tool is equipped, it fires a remote event which in turn decreases an int value via server script. Here's what I have.

local script in tool:

game:GetService("UserInputService").InputBegan:Connect(function(input, gameHandledEvent) 
	if gameHandledEvent then
		if input.KeyCode == Enum.KeyCode.G then 
			Bandaging:FireServer()
		end
	end
end)

game:GetService("UserInputService").InputEnded:Connect(function(input, gameHandledEvent)
	if gameHandledEvent then
		if input.KeyCode == Enum.KeyCode.G then 
			CancelBandaging:FireServer()
		end	
	end
end)

server script in tool:

function bandaging()
	print("sdasdsad")
	while wait() do
		if humanoid.Wounds.Value > 0 then
			if humanoid.Health > 0 then
				humanoid.Wounds.Value = humanoid.Wounds.Value - 1
			end
		end
	end
end



Bandaging.OnServerEvent:Connect(bandaging)

CancelBandaging.OnServerEvent:Disconnect(bandaging)

Both remote events are in the tool as well. It can detect when I press and release G just fine, but it doesn't seem to be firing the remote events. That or the server script isn't receiving it correctly? Any help is appreciated.

2 comments

1

You've been misinformed on the GameProcessed boolean. It indicates whether the game engine internally observed our input, and ultimately acted upon it. E.g. inputs bound via ContextActionService. Normally, we use this parameter as a debounce, therefore, adjust your code to check whether the game engine DIDN'T process your input. I recommend you look this up for more information.

0

Oh lol thanks!