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

ServerScriptService.Stats:7: Expected ')' (to close '(' at line 6), got 'local'?

Ok so, as you seen in the title the is a problem at this script, can you pls help me with it? ERROR: ServerScriptService.Stats:7: Expected ')' (to close '(' at line 6), got 'local'

local players = game:GetService("Players") local datastore = game:GetService("DataStoreService") local ds1 = datastore:GetDataService("ClickData") local ds2 = datastore:GetDataService("RebirthData")

players.PlayerAdded:connect(funtion(player) local folder = Instance.new("Folder") folder.name = "leaderstats" folder.Parent = player local folder2 = Instance.new("Folder") folder2.Name = "Stats" folder2.Parent = players

local currency1 = Instance.new("NumberValue")
currency1.Name = 'Clicks'
currency1.Parent = player.leaderstats
currency1.Value = ds1:GetAsync(player.UserId) or 0

local currency2 = Instance.new("NumberValue")
currency2.Name = 'Rebirths'
currency2.Parent = player.leaderstats
currency2.Value = ds2:GetAsync(player.UserId) or 0

end)

6 comments

0

Could you please fix the code block? It's really hard to read it this way.

0

local players = game:GetService("Players") local datastore = game:GetService("DataStoreService") local ds1 = datastore:GetDataService("ClickData") local ds2 = datastore:GetDataService("RebirthData") players.PlayerAdded:connect(funtion(player) local folder = Instance.new("Folder") folder.name = "leaderstats" folder.Parent = player local folder2 = Instance.new("Folder") folder2.

0

It don't let me type it all Idk how to fix it

0

Nvm fixed it but becarful when reading it XD

0

With fixing I meant putting all the code in one lua block. It's all over the place now and it's pretty hard to read it this way.

0

You have a syntax error somewhere, specifically, a parentheses that is not closed

1 answer

There’s multiple syntax errors in your script, but I think the one messing you up is the typo of ‘function’. Below should be the fixed version.

local players = game:GetService("Players")
local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataService("ClickData")
local ds2 = datastore:GetDataService("RebirthData")

players.PlayerAdded:Connect(function(player)
    local folder = Instance.new("Folder")
    folder.Name = "leaderstats"
    folder.Parent = player
    local folder2 = Instance.new("Folder")
    folder2.Name = "Stats"
    folder2.Parent = players

    local currency1 = Instance.new("NumberValue")
    currency1.Name = 'Clicks'
    currency1.Parent = player.leaderstats
    currency1.Value = ds1:GetAsync(player.UserId) or 0

    local currency2 = Instance.new("NumberValue")
    currency2.Name = 'Rebirths'
    currency2.Parent = player.leaderstats
    currency2.Value = ds2:GetAsync(player.UserId) or 0
end)

1 comment

0

Please, next time use codeblocks!

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