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: keys must be strings

Previous Thread :: Next Thread 
ByDefault is not online. ByDefault
Joined: 25 Jul 2014
Total Posts: 3197
05 Jan 2016 03:31 AM
What, why is this line erroring "keys must be strings"?

local inv = inventory[tostring(player.Name)]
workspace.ClientToServer:FireServer("SetInventory",inv)
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
05 Jan 2016 04:08 AM
Post the server's end of that.


Report Abuse
ByDefault is not online. ByDefault
Joined: 25 Jul 2014
Total Posts: 3197
05 Jan 2016 05:37 AM
This is on client:
workspace.ClientToServer:FireServer("SetInventory",inventory[player.Name]) -> errors "keys must be strings"


This is on server:
if event == "SetInventory" then
print(type(eventInfo)) -> table
inventory[client.Name] = eventInfo
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
05 Jan 2016 05:44 AM
Post the server's connection line
Report Abuse
ByDefault is not online. ByDefault
Joined: 25 Jul 2014
Total Posts: 3197
05 Jan 2016 05:46 AM
script.Parent.OnServerEvent:connect(function(client,event,eventInfo)
if event == "SetInventory" then
print(type(eventInfo))
inventory[client.Name] = eventInfo
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
05 Jan 2016 05:51 AM
If the local script errored at the sending part and the server still got the data that means the error is coming from the server.


Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
05 Jan 2016 05:56 AM
could you explain what you are doing
Report Abuse
ByDefault is not online. ByDefault
Joined: 25 Jul 2014
Total Posts: 3197
05 Jan 2016 06:01 AM
From the code snippets I've posted, can't you figure it out?

I've made an inventory system and most items get added client sided. So when I try to save it I need the client to set the inventory on the server
Report Abuse
ByDefault is not online. ByDefault
Joined: 25 Jul 2014
Total Posts: 3197
05 Jan 2016 06:10 AM
I've put tostring() inside every key when I try to index a dictionary, yet the error still occurs.
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
05 Jan 2016 06:11 AM
@ByDefault is this for that one guy that said he wanted an inventory made?

anyways your client work makes no sense because its almost as if you're running every players inventory. also you're doing [tostring(player.Name)] which makes absolutely no sense because player.Name already returns a string.

also if you're making an inventory why don't you just make a table with all the items in it, add items on the server once a character obtains an item, and fire the client with the updated items?

create a table guide on the server which relies on strings that relates to ingame objects, and save a player's inventory table when a player gets an object

that would be the smartest way to do this. this way you dont have to worry about things not getting saved, nor any exploits.
Report Abuse
Jilixi is not online. Jilixi
Joined: 20 Jan 2009
Total Posts: 1016
05 Jan 2016 06:17 AM
If this is for me you don't have to continue; Climaximus has it under control; Sorry for any wasted time friend.
Report Abuse
ByDefault is not online. ByDefault
Joined: 25 Jul 2014
Total Posts: 3197
05 Jan 2016 06:18 AM
No this is for my own mining game

http://www.roblox.com/games/336457286/Gold-Diggers
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
05 Jan 2016 06:32 AM
@ByDefault then by all means, take my advice. its the best way to go about the situation.
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