Help with blocking function

Hi there! Im trying to make a blocking function for my fighting game, most of the code is going to be handled in the weapon that deals damage but all i need right now is this to work. When i press Q the “Blocking” bool value in the player does not change, nor does anything go to the output. (I am sorry in advance for any sins i have committed with this script)

Code:

function onKeyPress(inputObject, gameProcessedEvent)
	if (not gameProcessedEvent and inputObject.KeyCode == Enum.KeyCode.Q) then
		humanoid.Parent.Blocking.Value = true
		print(humanoid.Parent.Blocking.Value)
	
	end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

I tested the code and it works fine.
Where exactly is the script located?

In the tool’s main script. I have no idea why it isnt working for me, the script normally works just fine.

Just to test something, does it work if you put the script into StarterGui?

that’s odd, it prints it into the output only in startergui

This looks like a LocalScript. Any changes you make to instances via the client cannot be accessed/viewed from the server. Given there’s no errors, it works, but you’ll have to send a signal through a RemoteEvent and then change the blocking value on a server script.

It is being changed on a server script, as everything in the tool currently is handled on the server
image
When i changed the value in startergui, i used a local script and it worked?

Okay, nevermind. What i’ve done now is have a local script that listens for it, fires a remote event in the tool and then the server script listens to that remote event and fires the function, i think UIS only works on client (unless i did something wrong)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.