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

Workspace.DataSaver:20 :"=" expected near number how to fix??

Asked by 5 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("Folder",player)
 folder.Name = "leaderstats"
 local currency1 = Instance.new("IntValue",folder)
 currency1.Name = "Money"

 local save = DataStore:GetAsyncz(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 load = {player.leaderstats:FindFirstChild("Name").Value}
 DataStore:SetAsync(key,load)Script Number=2 (Which is inside of StarterGui):local player = script.Parent.Parent
local leaderboard = player:WaitForChild("leaderstats")
local currency1 = leaderboard:WaitForChild("Name")while wait(5) do
 currency1.Value = currency1.Value + 1
end?

Also if this script have any promblems please do me a favor and tell me thx :) ps: i am new in this scripting thingy so forgive my scripting skills :)

0
check like 10. User#5423 17 — 5y
0
Why do you have a while loop in the PlayerRemoving event o.o User#5423 17 — 5y
0
There is no silent Z in GetAsync ABK2017 406 — 5y
0
You also need spaces on line 20 “ = “ ABK2017 406 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

this script in Workspace. Script 1:

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

this script in StarterGui. Script 2:

local Interval = 5 --put in number. If you set as 5, player get money every 5 seconds.
local GetMoney = 20 -- put in number. If you set as 20, player get 20 moneys.
local Player =  script.Parent.Parent
local Folder = Player:WaitForChild("leaderstats")
local Currency1 = Folder:WaitForChild("Money")
while wait(Interval) do
 Currency1.Value = Currency1.Value + GetMoney
end

Good luck :)

symbol of " -- " will be the comment. Only that line will be a comment. ex)

(script)
--Hello, this is Comment
(script)
Ad

Answer this question