Now, I created a LocalScript with this script in it:
game:GetService("UserInputService").InputBegan:Connect(function(input,progress)
if progress == false or nil then
print(input)
game.ReplicatedStorage.SpellRemoteEvents.KeyBindSpell:FireServer(input,game.Players.LocalPlayer:GetMouse(),game.Players.LocalPlayer:GetMouse().Target)
end
end)
In the LocalScript it prints the input which is InputObject. After I connected from the ServerScript to the KeyBindSpell : Remote Event it prints the nil:
You need to check which button player is pressing from the client and then fire the remote, like this.
local key = "E" -- button
game:GetService("UserInputService").InputBegan:Connect(function(input,typing)
if typing == true then
return
end
if input.InputBegan == Enum.KeyCode[key] then
game.ReplicatedStorage.SpellRemoteEvents.KeyBindSpell:FireServer(game.Players.LocalPlayer:GetMouse(),game.Players.LocalPlayer:GetMouse().Target)
end
end)
Nvm. I made it now so, I created a table with just the all the letters in the LocalScript. Then I check after a button got pressed if the button in the table is and if yes, fire it to the Server Script.
local key = "E" -- button
game:GetService("UserInputService").InputBegan:Connect(function(input,typing)
if typing == true then
return
end
if input.InputBegan == Enum.KeyCode[key] then
game.ReplicatedStorage.SpellRemoteEvents.KeyBindSpell:FireServer(game.Players.LocalPlayer:GetMouse(),game.Players.LocalPlayer:GetMouse().Target)
end
end)
You mean this? from what I see is just check if player is pressing the right key or not and then fire the remote.