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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 28 Apr 2009 |
| Total Posts: 660 |
|
| |
|
MattJon
|
  |
| Joined: 28 Apr 2009 |
| Total Posts: 660 |
|
| |
|
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 |
|
|
|
| 25 May 2015 07:46 PM |
| Datastores only work in server scripts. |
|
|
| Report Abuse |
|
|