Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

"(" expected to (close "("at line 20) near <eof> HOW TO FIX??

Asked by 6 years ago
Edited 6 years ago
local DataStore =
 game:GetService("DataStoreService"):GetDataStore("StoreName")

    game.Players.PlayerAdded:connect(function(player)
     local key = "key-"..(player.userId)
     local folder = Instance.new("Folder",player)
     folder.Name = "leaderstats"
     local currency1 = Instance.new("IntValue",folder)
     currency1.Name = "Money"

     local save = DataStore:GetAsync(key)
     if save then
      currency1.Value = save[1]
     else
      local load = {currency1.Value}
      DataStore:SetAsync(key,load)
     end
end)

    game.Players.PlayerRemoving:connect(function(player)
     local key = "key-"..(player.userId)
     local Folder = player:WaitForChild("leaderstats")
     local load = {leaderstats:FindFirstChild("Money").Value}
    DataStore:SetAsync(key,load)
end

FORGIVE ME IF I AM ASKING MANY QUESTIONS :( I AM NEW IN THIS SCRIPTING WORLD I AM ORIGINALLY FROM THE BUILDING WORLD BUT I WANTED TO DO A NEW THING BUT I NEED SOME ADVICE FROM THE SCRIPTING WORLD AND ALSO THIS SCRIPT IS FOR DATA SAVING IF YOU CAN ANSWER THIS PLEASE SAY IF THIS IS A DATA SAVING SCRIPT CAUSE I HAVE BUILT A BANK BUT THE PLAYERS MONEY WON'T SAVE IF THEY QUIT. ALSO IF THERE'S A NY MORE PROMBLEMS PLEASE FIX THEM :(.

this is my project btw: https://www.roblox.com/games/2259153311/AY3
i think its good.

0
( was expected to close "(" at line 20 near <eof> (end of file/end of script/whatever). How simple was that error? hiimgoodpack 2009 — 6y

2 answers

Log in to vote
0
Answered by
AIphanium 124
6 years ago
local DataStore =
 game:GetService("DataStoreService"):GetDataStore("StoreName")

    game.Players.PlayerAdded:connect(function(player)
     local key = "key-"..(player.userId)
     local folder = Instance.new("Folder",player)
     folder.Name = "leaderstats"
     local currency1 = Instance.new("IntValue",folder)
     currency1.Name = "Money"

     local save = DataStore:GetAsync(key)
     if save then
      currency1.Value = save[1]
     else
      local load = {currency1.Value}
      DataStore:SetAsync(key,load)
     end
end)

    game.Players.PlayerRemoving:connect(function(player)
     local key = "key-"..(player.userId)
     local Folder = player:WaitForChild("leaderstats")
     local load = {leaderstats:FindFirstChild("Money").Value}
    DataStore:SetAsync(key,load)
end)

Have fun.

There is no reason to accept this answer.

0
And also, do not use free scripts without the knowledge of what they do. AIphanium 124 — 6y
Ad
Log in to vote
0
Answered by
Oficcer_F 207 Moderation Voter
6 years ago

Here is the fixed script:

local DataStore =
 game:GetService("DataStoreService"):GetDataStore("StoreName")

    game.Players.PlayerAdded:connect(function(player)
     local key = "key-"..(player.userId)
     local folder = Instance.new("Folder",player)
     folder.Name = "leaderstats"
     local currency1 = Instance.new("IntValue",folder)
     currency1.Name = "Money"

     local save = DataStore:GetAsync(key)
     if save then
      currency1.Value = save[1]
     else
      local load = {currency1.Value}
      DataStore:SetAsync(key,load)
     end
end)

    game.Players.PlayerRemoving:connect(function(player)
     local key = "key-"..(player.userId)
     local Folder = player:WaitForChild("leaderstats")
     local load = {leaderstats:FindFirstChild("Money").Value}
    DataStore:SetAsync(key,load)
end)

Thanks for accepting answer

Answer this question