generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: RemoteEvent + User Input

Previous Thread :: Next Thread 
timothy_teakettle is not online. timothy_teakettle
Joined: 28 Nov 2008
Total Posts: 300
27 Sep 2017 01:30 PM
I have a variable 'key' that I send to a remote event, at the remote events side of things 'key' is always nil.

-- Code in the remote event
script.Parent.OnServerEvent:connect(function(player,key)
print(player, key)
end)

-- Code in local script that triggers the remote event
game:GetService("UserInputService").InputBegan:connect(function(key,gp)
if not gp then
game.Workspace.RemoteEvent:FireServer(key)
end
end)

--
what do
Report Abuse
GodShowsTheWay is not online. GodShowsTheWay
Joined: 27 Oct 2014
Total Posts: 7180
27 Sep 2017 01:39 PM
First of all, you should be using Connect() not connect()

UserInputService passes on InputObject, not a key. If you want to get the key you need to use key.KeyCode

-- Code in the remote event
script.Parent.OnServerEvent:Connect(function(player, key)
print(player, key)
end)

-- Code in local script that triggers the remote event
game:GetService("UserInputService").InputBegan:Connect(function(inputObject, gp)
if not gp then
game.Workspace.RemoteEvent:FireServer(inputObject.KeyCode)
end
end)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image