In a script I have this. The script is in a model in the Workspace.

function onKeyPress(actionName, userInputState, inputObject)
if userInputState == Enum.UserInputState.Begin and InUse == 0 and Players.LocalPlayer.PlayerScripts.Allowed.Value == 1 and script.Parent.Localizer.Value == 1 then 

print("Stuff happens here")
		
	end
end
 
game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.E)

Using this works fine in Solo, but it doesn't work in a Server. I'm thinking it's because Keyboard Input is having a problem when I play on a server.

If I'm wrong please let me know. I'm trying to look for an alternative, but I'm hoping to stick to this format.

2 comments

0

May you explain what you're trying to do? I'm kinda of confused but if you wanted to where if the player clicks a certain key then reply.

0

What I'm trying to do is that when a player presses E on a model with the script in it, it runs code below it. The problem is, is that if I press E while on a Test Server, the keypress isn't received, but it works on Play Solo.