I am making a stat saving script but it just says ServerScriptService.Script:38: Expected ')' (to close '(' at line 34), got 'end' when i test the game... I turned on HTTP and API... Heres the script:
**game.Players.PlayerAdded:connect(function(player)
local StartingMoney = (0) -------------------------------------------------------- local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local money = Instance.new("NumberValue") sticks.Name = "Sticks" sticks.Parent = leaderstats sticks.Value = StartingSticks
local dataStore = game:GetService("DataStoreService"):GetDataStore("SticksData")
starterSticks = 0--This is the starter money
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = plr local money = Instance.new("IntValue") sticks.Name = "Sticks" --Put ur currency name here, mine is Money sticks.Value = dataStore:GetAsync(plr.UserId) or starterSticks sticks.Parent = leaderstats
end)
game.Players.PlayerRemoving:Connect(function(plr)
dataStore:SetAsync(plr.UserId, plr.leaderstats.Sticks.Value)
end**
Howdy!
You're missing a parenthesis at the very bottom of your script. Replace your PlayerRemoving
function with what I got below.
game.Players.PlayerRemoving:Connect(function(plr) dataStore:SetAsync(plr.UserId, plr.leaderstats.Sticks.Value) end)
You're also missing a "end)" at the end of your PlayerAdded. But before I address that, why do you have a PlayerAdded
function INSIDE of a PlayerAdded
function? It's a little arbitrary.
I recommend that you just remove the line in the middle of your script that says game.Players.PlayerAdded:Connect(function(plr)
. It's breaking the script and it's too unnecessary to keep in so there is no reason to fix it. Just remove it.
I removed game.Players.PlayerAdded:Connect(function(plr) but now it says ServerScriptService.Script:34: Expected 'end' (to close 'function' at line 1), got <eof>; did you forget to close 'function' at line 21?
Heres the script:
game.Players.PlayerAdded:connect(function(player)
local StartingMoney = (0) -------------------------------------------------------- local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local money = Instance.new("NumberValue") sticks.Name = "Sticks" sticks.Parent = leaderstats sticks.Value = StartingSticks
local dataStore = game:GetService("DataStoreService"):GetDataStore("SticksData")
starterSticks = 0--This is the starter money
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = plr local money = Instance.new("IntValue") sticks.Name = "Sticks" sticks.Value = dataStore:GetAsync(plr.UserId) or starterSticks sticks.Parent = leaderstats dataStore:SetAsync(plr.UserId, plr.leaderstats.Sticks.Value)
end)