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
 

Am I doing the Datastores wrong?

Previous Thread :: Next Thread 
CrammelApple is not online. CrammelApple
Joined: 02 Feb 2014
Total Posts: 8
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
zach0arythesniper79 is not online. zach0arythesniper79
Joined: 18 Aug 2011
Total Posts: 211
04 Jul 2016 07:45 PM
Bump.
Report Abuse
BanTech is not online. 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
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