How to make player input into a server script using remote events

im just trying to get local inputs to server side using remote events so i can run magic attacks in a server script

image

The server script keeps erroring and i have little to no coding experience and i need help

any help would be appreciated!

1 Like

You can’t send an input from the player (I think), and if I am right it is because of the context it is in, you are sending a client value to a server. You can always just run the remote event with the code they pressed. So:

game:GetService("ReplicatedStorage").KeyBindEvent:FireServer(input.KeyCode);

And if that doesn’t work just send a string representation:

game:GetService("ReplicatedStorage").KeyBindEvent:FireServer("F");
2 Likes

Client:

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(input) 
game:GetService("ReplicatedStorage").KeyBindEvent:FireServer(UIS:GetStringForKeyCode(input.KeyCode))
end)

Server:

game:GetService("ReplicatedStorage").KeyBindEvent.OnServerEvent:Connect(function(player, key)
   print(player.Name.." has pressed "..key.." key")
end)
2 Likes

image
local script showing this error

1 Like

Sorry, its called GetStringForKeyCode

1 Like


alr we are getting close

Edited the script. Im writing this at late night so…

1 Like

ah alr u have a good night and thanks for the help

2 Likes

To anyone who is for some reason using the keybind space, its " " just a space, not nil or empty, but just a space…