So I am trying to do a script (located in ServerScriptService) that detects if a key is pressed so it will call a function, but I don't know how to get the name of the player who pressed it.
game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.R then print("fireball pls") end end)
I can't use LocalPlayer since it's a server-sided script.
user input service and getmouse() only work on the client so you will need to set up a remote event and localscript to detect when a player presses a key