It’s meant to add a number and save it. For some reason it never adds the number. I know it saves.
local success, content = pcall(function()
return require(script.NonNative.GetStoreType)
.GetDataStore("3V4B62N5E5488C21AV591031W")
:GetAsync(game.Workspace.Blocks:WaitForChild("WorldConfig"):FindFirstChild("WorldID").Value)
end)
if not success then
warn("DataStore error: Unable to fetch world data")
return
end
if not content.Additional.RatingData then
content.Additional.RatingData = {
Star1 = 0,
Star2 = 0,
Star3 = 0,
Star4 = 0,
Star5 = 0,
}
end
local function getArea()
if votenum == 1 then
return content.Additional.RatingData.Star1
elseif votenum == 2 then
return content.Additional.RatingData.Star2
elseif votenum == 3 then
return content.Additional.RatingData.Star3
elseif votenum == 4 then
return content.Additional.RatingData.Star4
else
return content.Additional.RatingData.Star5
end
end
local place = getArea()
place = place + 1
local success = pcall(function()
return require(script.NonNative.GetStoreType)
.GetDataStore("3V4B62N5E5488C21AV591031W")
:SetAsync(game.Workspace.Blocks:WaitForChild("WorldConfig"):FindFirstChild("WorldID").Value, content)
end)
if not success then
warn("DataStore error: Unable to update world vote")
return
end
table.insert(userprofile.RatedWorlds, game.Workspace.Blocks:WaitForChild("WorldConfig"):FindFirstChild("WorldID").Value)
local success = pcall(function()
return require(script.NonNative.GetStoreType)
.GetDataStore("GZ8R1K7X5L0V2D4T3Y9J")
:SetAsync("N3J7F8M2W1L5Z0R4T6P9-" .. player.UserId, userprofile)
end)
if not success then
warn("DataStore error: Unable to update user profile")
end
At no point are you saving the value of place
. Where are you intending for it to save?
Also, Why are you using names like “3V4B62N5E5488C21AV591031W” for your datastores? It’s much better to just do something like “Builds” or “Money”
could probably be why
[[local success, content = pcall(function()
return require(script.NonNative.GetStoreType)
.GetDataStore(“3V4B62N5E5488C21AV591031W”)
:GetAsync(game.Workspace.Blocks:WaitForChild(“WorldConfig”):FindFirstChild(“WorldID”).Value)
end)
if not success then
warn("DataStore error: Unable to fetch world data")
return
end
if not content.Additional.RatingData then
content.Additional.RatingData = {
Star1 = 0,
Star2 = 0,
Star3 = 0,
Star4 = 0,
Star5 = 0,
}
end
if votenum == 1 then
content.Additional.RatingData.Star1 = content.Additional.RatingData.Star1 + 1
elseif votenum == 2 then
content.Additional.RatingData.Star2 = content.Additional.RatingData.Star2 + 1
elseif votenum == 3 then
content.Additional.RatingData.Star3 = content.Additional.RatingData.Star3 + 1
elseif votenum == 4 then
content.Additional.RatingData.Star4 = content.Additional.RatingData.Star4 + 1
elseif votenum == 5 then
content.Additional.RatingData.Star5 = content.Additional.RatingData.Star5 + 1
end
local success = pcall(function()
return require(script.NonNative.GetStoreType)
.GetDataStore("3V4B62N5E5488C21AV591031W")
:SetAsync(game.Workspace.Blocks:WaitForChild("WorldConfig"):FindFirstChild("WorldID").Value, content)
end)
if not success then
warn("DataStore error: Unable to update world vote")
return
end
table.insert(userprofile.RatedWorlds, game.Workspace.Blocks:WaitForChild("WorldConfig"):FindFirstChild("WorldID").Value)
local success = pcall(function()
return require(script.NonNative.GetStoreType)
.GetDataStore("GZ8R1K7X5L0V2D4T3Y9J")
:SetAsync("N3J7F8M2W1L5Z0R4T6P9-" .. player.UserId, userprofile)
end)
if not success then
warn("DataStore error: Unable to update user profile")
end]]
however after applying it into the game it doesnt save still
also if you’re wondering heres my full script
game.ReplicatedStorage.Files.Events.NonNative.VoteFinishedEvent.OnServerEvent:Connect(function(player, votenum)
player.PlayerGui:WaitForChild("UserGUIHandler"):FindFirstChild("Windows"):FindFirstChild("MoreWindows"):FindFirstChild("Rating").Visible = false
local success, userprofile = pcall(function()
return require(script.NonNative.GetStoreType).GetDataStore("GZ8R1K7X5L0V2D4T3Y9J"):GetAsync("N3J7F8M2W1L5Z0R4T6P9-" .. player.UserId)
end)
if not success then
warn("DataStore error: Unable to fetch user profile")
return
end
if table.find(userprofile.RatedWorlds, game.Workspace.Blocks:WaitForChild("WorldConfig"):WaitForChild("WorldID").Value) then
local params = {
buttonCount = 1,
Image = 0,
CloseAllowed = true,
Time = 0,
messageText = "You have already rated this world.",
button1Text = "Okay",
targetPlayerName = player.Name
}
require(script.MessageService).Error(params)
return
else
local content = require(script.NonNative.GetStoreType)
.GetDataStore("3V4B62N5E5488C21AV591031W")
:GetAsync(game.Workspace.Blocks:WaitForChild("WorldConfig"):FindFirstChild("WorldID").Value)
if not content.Additional.RatingData then
content.Additional.RatingData = {
Star1 = 0,
Star2 = 0,
Star3 = 0,
Star4 = 0,
Star5 = 0,
}
end
if votenum == 1 then
content.Additional.RatingData.Star1 = content.Additional.RatingData.Star1 + 1
elseif votenum == 2 then
content.Additional.RatingData.Star2 = content.Additional.RatingData.Star2 + 1
elseif votenum == 3 then
content.Additional.RatingData.Star3 = content.Additional.RatingData.Star3 + 1
elseif votenum == 4 then
content.Additional.RatingData.Star4 = content.Additional.RatingData.Star4 + 1
elseif votenum == 5 then
content.Additional.RatingData.Star5 = content.Additional.RatingData.Star5 + 1
end
require(script.NonNative.GetStoreType)
.GetDataStore("3V4B62N5E5488C21AV591031W")
:SetAsync(game.Workspace.Blocks:WaitForChild("WorldConfig"):FindFirstChild("WorldID").Value, content)
table.insert(userprofile.RatedWorlds, game.Workspace.Blocks:WaitForChild("WorldConfig"):FindFirstChild("WorldID").Value)
require(script.NonNative.GetStoreType)
.GetDataStore("GZ8R1K7X5L0V2D4T3Y9J")
:SetAsync("N3J7F8M2W1L5Z0R4T6P9-" .. player.UserId, userprofile)
end
end)