|
| 04 Jul 2016 07:21 PM |
Basically, i'm doing a datastore script with a like/dislike ratio and apparently when i click the dislike button, it does not change anything. So, am I doing something wrong here? Because no errors show up and the script isn't disabled.
---- dislike button script:
local obj = "Flower" -- Put the name of the object between quotes
local objname = obj.."Rating"
local DataStore = game:GetService("DataStoreService"):GetDataStore(objname)
script.Parent.ClickDetector.MouseClick:connect(function(player)
local key = obj.."Dislikes" local playerkey = "plrvote_"..player.userId
local playervote = DataStore:GetAsync(playerkey) local Datastor = DataStore:GetAsync(key)
if Datastor ~= nil then local dataAdd = Datastor+1 DataStore:SetAsync(key,dataAdd) print (Datastor.." Dislikes") DataStore:SetAsync(playerkey,"voted") else DataStore:SetAsync(key,0) local dataAdd = Datastor+1 DataStore:SetAsync(key,dataAdd) DataStore:SetAsync(playerkey,"voted")
end
end) ---- dislikes "viewer" script:
local obj = "Flower"
local objname = obj.."Rating"
local DataStore = game:GetService("DataStoreService"):GetDataStore(objname)
local key = obj.."Dislikes"
while true do local Datastor = DataStore:GetAsync(key) if Datastor ~= nil then script.Parent.Title.Text = "This model has "..Datastor.." Dislikes" end wait() end |
|
|
| Report Abuse |
|
| |
BanTech
|
  |
| Joined: 31 Dec 2015 |
| Total Posts: 886 |
|
|
| 04 Jul 2016 07:50 PM |
You are doing way too many get requests. Firstly try using UpdateAsync to prevent you having to get, then set, and to prevent any data loss. Secondly, get rid of that horrid while loop and use the OnUpdate event.
You are 100% going to reach the limit with this setup. Try reading the wiki page on data stores to understand why, and to see an example of the two methods I mentioned. |
|
|
| Report Abuse |
|