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
 

DataStore probs.

Previous Thread :: Next Thread 
MattJon is not online. MattJon
Joined: 28 Apr 2009
Total Posts: 660
17 Dec 2014 03:30 PM
plr is defined. voote is defined as a string, a one letter string, a letter from A-F. e is a bool value.

16:26:40.974 - keys must be strings
16:26:40.975 - Script 'Players.Player1.PlayerGui.ScreenGui.Frame.voting.voteframe.', Line 13 - global vote
16:26:40.976 - Script 'Players.Player1.PlayerGui.ScreenGui.Frame.voting.voteframe.', Line 145
16:26:40.977 - Stack End
16:26:40.978 - Disconnected event because of exception
----------------------------------------------
local DataStore = game:GetService("DataStoreService"):GetDataStore("VoteTable")
local votetable = DataStore:GetAsync("vtable")


function vote()
table.insert(votetable, tostring(plr.userId), tostring(""..plr:GetRankInGroup(949398)..""..voote.Value..""))

-- LINE 13 vv
DataStore:SetAsync("vtable", votetable)
-- LINE 13 ^^

end

function revote()
votetable[tostring(plr.userId)] = tostring(""..plr:GetRankInGroup(949398)..""..voote.Value.."")
DataStore:SetAsync("vtable", votetable)
end



-- Stuff here is just vanity



script.Parent.MouseButton1Down:connect(function()
if e.Value == true then
e.Value = false
if votetable[plr.userId] == nil then

-- LINE 145 vv
vote()
-- LINE 145 ^^

wait(.5)
elseif votetable[plr.userId] ~= nil then
revote()
wait(.5)
end
end
end)
Report Abuse
MattJon is not online. MattJon
Joined: 28 Apr 2009
Total Posts: 660
17 Dec 2014 03:32 PM
I don't get why is keeps saying "keys must be strings". The key for the DataStore is obviously a string - "vtable"...
Report Abuse
LucasLua is not online. LucasLua
Joined: 18 Jun 2008
Total Posts: 7386
17 Dec 2014 03:47 PM
It is complaining about your votetable. I've had issues where Roblox will deny saving a mixed index/key table (Some keys that are strings and some indexes that are standard integers) also.

The reason is that they use JSON to turn the table into a string internally, and then when the user asks for the key with the JSON string Roblox decodes it back into a table. There are some annoying limitations that go with this...

http://wiki.roblox.com/index.php?title=Data_store#Tables_with_mixed_list_.2F_record_style_will_be_cut_off
Report Abuse
MattJon is not online. MattJon
Joined: 28 Apr 2009
Total Posts: 660
17 Dec 2014 08:06 PM
How do you suggest I proceed? I need to save the userId so I can check if a player has voted, and I need to save their vote ("A","B","C", etc.).
Report Abuse
MattJon is not online. MattJon
Joined: 28 Apr 2009
Total Posts: 660
17 Dec 2014 09:07 PM
bump-a-lump
Report Abuse
MattJon is not online. MattJon
Joined: 28 Apr 2009
Total Posts: 660
17 Dec 2014 10:42 PM
BUMP
Report Abuse
iceman72 is not online. iceman72
Joined: 08 Jun 2008
Total Posts: 786
17 Dec 2014 11:09 PM
Sounds like you could save the letters as numbers similar to something like the ascii code, that way they all fit in one table. (the booligan as just a 0 or 1 would have to be done too)
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
25 May 2015 07:46 PM
Datastores only work in server scripts.
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