Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Im trying to the My Reviews but It dosnt Work Properly [SOLVED]?

This is the script to save the reviews Thumbs Up, but when someone review it Dosnt add any reviews and Sometimes adds like 30 Reviews to the value when Its suppose to add 1

local ReviewName = "ThumbsUp"
local DS = game:GetService("DataStoreService"):GetDataStore("ReviewThumbsUp9785292371")

if not DS:GetAsync(ReviewName.."-Review") then
DS:SetAsync(ReviewName.."-Review",0)
end

local Reviews = DS:GetAsync(ReviewName.."-Review")
game.Workspace.ReviewValues.ThumbsDown.Value = DS:GetAsync(ReviewName.."-Review")

function PrintOut(Value)
print(Value)
end

game.Workspace.ReviewValues.ThumbsUp.Changed:Connect(function()
DS:IncrementAsync(ReviewName.."-Review",game.Workspace.ReviewValues.ThumbsUp.Value)
DS:OnUpdate(ReviewName.."-Review",PrintOut)
wait(1)
game.Workspace.ReviewValues.ThumbsUp.Value = DS:GetAsync(ReviewName.."-Review")
end)

coroutine.resume(coroutine.create(function()
while wait() do
local Reviews = DS:GetAsync(ReviewName.."-Review")
game.Workspace.ReviewValues.ThumbsUp.Value = DS:GetAsync(ReviewName.."-Review")
end
end))

3 comments

0

How does it not work properly? (also indent your code)

0

When someone reviews the value dosnt go up and sometimes adds like 30 reviews to the value

1

I dont even know what your trying to do.. You cant just post a question and paste some code. You will need to explain to us.

3 answers

I may not be able to pinpoint your error, but I know for a fact that this doesent work for multiple reasons. Reason 1, in my eyes you method of getting the data just gets the same data in certain spots and uses it for different stuff. Reason 2, at line 22 just use spawn(function(), reason 3, calling data out of a datastore every .01 seconds or whatever you have wait() set to, is way to often. Your overloading the APIs. This would be a lot easier to manage if you would reformat your code properly by indenting. Then change what I said above. Please edit your question when you have changed the above.

1 comment

0

PLUS, your code and question were phrased improperly.

I figured this out, it was Because the Datastore was ImcrementAsync instead of SetAsync

the code is kinda of hard to read and understand here is what i think ur trying to do:

when a player clicks some sort of button or whatever to thumbs up something, it will add to the number of thumbs up in the store data of current reviews and similarly to the thumbs down right? and the reviews are not for a specific player, but generally for everyone to rate and see

if so, here is better way to do it.

Note: takes 5 seconds to update

local datstoreName = "name of data store goes between the the quotes"
local key = "reviews unique key goes here"
local datastore = game:GetService("DatastoreService"):GetDatastore(datastoreName)

local awaitingReviews = {}
local db = false

function rateProduct(rating) --change this name
	if not db then
		db = true
		reviews = datastore:GetAsync(key)
		reviews = (reviews or 0)+rating
	
		datastore:SetAsync(key,reviews)
		wait(5)
		db = false
		table.foreach(awaitingReviews,rateProduct)
	else
		awaitingReviews[#awaitingReviews +1] = rating
	end
end

so how this function works is:

you pass it either a 1 or -1 to to indicate thumbs or down:

-1 down

1 up

if u have some sort of a thing that lets players see both numbers of likes and dislikes then you can simply add an if statement to modify the function

sorry the code is not in the best form. i was in a car accident and came out injured, which is kind of limited me from doing my best; sorry

This discussion is preserved as it was. New answers, comments, and votes are closed.