Expected identifier when parsing expression, got ')'

Hey, so saw from similar threads people ask for the specific code involved, so figured I’d put it here from the get go. I have no idea about scripting, this is a mix of 3/4 scripts I have jumbled together and up until I added the part marked with ** it all worked fine.

I have added an ‘end’ and removed an ‘end’ and the problem doesn’t resolve itself. Kind of at a loss.

Any help in where it’s gone wrong would be appreciated. Thanks!

game.Players.PlayerAdded:Connect(function(p)

local dss = game:GetService("DataStoreService")
local levelDS = dss:GetDataStore("CrateServer")
	
local ls = Instance.new("Folder")
ls.Name = "leaderstats"
ls.Parent = p

local Kills = Instance.new("IntValue")
Kills.Name = "Kills"
Kills.Value = 0
Kills.Parent = ls

local Level = Instance.new("IntValue")
Level.Name = "Level"
Level.Parent = ls

local cash = Instance.new("IntValue")	
cash.Name = "Aureus"
cash.Value = 0
cash.Parent = ls

**local KillsRequirement = 10

Kills.Changed:Connect(function(NewValue)
	if NewValue >= KillsRequirement then
		print(p.Name.." has levelled up! Current Level: ", Level.Value)
		Kills.Value = 0
		Level += 1
		KillsRequirement *= Level.Value
	end**

local crates = game.ReplicatedStorage:WaitForChild(“Crates”)

game.ReplicatedStorage.CrateRE.OnServerEvent:Connect(function(plr, crateType, crateTime)
	
if crates:FindFirstChild(crateType) then

local price = crates[crateType].Price.Value

	if plr.leaderstats.Aureus.Value >= price then
		
		plr.leaderstats.Aureus.Value = plr.leaderstats.Aureus.Value - price
		
		local unboxableWeapons = crates[crateType]:GetChildren()
		
		local chosenWeapon 
		repeat chosenWeapon = unboxableWeapons[math.random(#unboxableWeapons)] wait() until chosenWeapon:IsA("Tool")
		
		game.ReplicatedStorage.CrateRE:FireClient(plr, chosenWeapon)
		
		wait(crateTime + 1)
		
		chosenWeapon:Clone().Parent = plr.Backpack
 end)
game.Players.PlayerAdded:Connect(function(p)
	local dss = game:GetService("DataStoreService")
	local levelDS = dss:GetDataStore("CrateServer")

	local ls = Instance.new("Folder")
	ls.Name = "leaderstats"
	ls.Parent = p

	local Kills = Instance.new("IntValue")
	Kills.Name = "Kills"
	Kills.Value = 0
	Kills.Parent = ls

	local Level = Instance.new("IntValue")
	Level.Name = "Level"
	Level.Parent = ls

	local cash = Instance.new("IntValue")	
	cash.Name = "Aureus"
	cash.Value = 0
	cash.Parent = ls
end)

local KillsRequirement = 10

Kills.Changed:Connect(function(NewValue)
	if NewValue >= KillsRequirement then
		print(p.Name.." has levelled up! Current Level: ", Level.Value)
		Kills.Value = 0
		Level += 1
		KillsRequirement *= Level.Value
	end
end)

		local crates = game.ReplicatedStorage:WaitForChild("Crates")

	game.ReplicatedStorage.CrateRE.OnServerEvent:Connect(function(plr, crateType, crateTime)

		if crates:FindFirstChild(crateType) then
			local price = crates[crateType].Price.Value

			if plr.leaderstats.Aureus.Value >= price then

				plr.leaderstats.Aureus.Value = plr.leaderstats.Aureus.Value - price

				local unboxableWeapons = crates[crateType]:GetChildren()

				local chosenWeapon 
				repeat chosenWeapon = unboxableWeapons[math.random(#unboxableWeapons)] wait() until chosenWeapon:IsA("Tool")

				game.ReplicatedStorage.CrateRE:FireClient(plr, chosenWeapon)

				wait(crateTime + 1)

				chosenWeapon:Clone().Parent = plr.Backpack
			end
			
		end
	end)

try this

plaaees send it in a codeblock its so messy

local dss = game:GetService("DataStoreService")
local levelDS = dss:GetDataStore("CrateServer")

local ls = Instance.new("Folder")
ls.Name = "leaderstats"
ls.Parent = p

local Kills = Instance.new("IntValue")
Kills.Name = "Kills"
Kills.Value = 0
Kills.Parent = ls

local Level = Instance.new("IntValue")
Level.Name = "Level"
Level.Parent = ls

local cash = Instance.new("IntValue")	
cash.Name = "Aureus"
cash.Value = 0
cash.Parent = ls

local KillsRequirement = 10

Kills.Changed:Connect(function()
	if NewValue >= KillsRequirement then
		print(p.Name.." has levelled up! Current Level: ", Level.Value)
		Kills.Value = 0
		Level += 1
		KillsRequirement *= Level.Value
	end

	local crates = game.ReplicatedStorage:WaitForChild("Crates")

	game.ReplicatedStorage.CrateRE.OnServerEvent:Connect(function(plr, crateType, crateTime)
		if crates:FindFirstChild(crateType) then
			local price = crates[crateType].Price.Value
			if plr.leaderstats.Aureus.Value >= price then
				plr.leaderstats.Aureus.Value = plr.leaderstats.Aureus.Value - price

				local unboxableWeapons = crates[crateType]:GetChildren()

				local chosenWeapon 
				repeat chosenWeapon = unboxableWeapons[math.random(#unboxableWeapons)] wait() until chosenWeapon:IsA("Tool")

				game.ReplicatedStorage.CrateRE:FireClient(plr, chosenWeapon)

				wait(crateTime + 1)

				chosenWeapon:Clone().Parent = plr.Backpack
			end
		end
	end)
end)

Sorry, adding the asterisks must have messed it up.

Your fix meant that ‘ls.Parent = p’ the ‘p’ is underlined blue.

Also ‘if NewValue >= KillsRequirement then
print(p.Name…" has levelled up! Current Level: ", Level.Value)’

Both ‘NewValue’ and the ‘p’ are underlined blue here. It says Unknown global.

i didnt see the player added thing above

game.Players.PlayerAdded:Connect(function(p)
	local dss = game:GetService("DataStoreService")
	local levelDS = dss:GetDataStore("CrateServer")

	local ls = Instance.new("Folder")
	ls.Name = "leaderstats"
	ls.Parent = p

	local Kills = Instance.new("IntValue")
	Kills.Name = "Kills"
	Kills.Value = 0
	Kills.Parent = ls

	local Level = Instance.new("IntValue")
	Level.Name = "Level"
	Level.Parent = ls

	local cash = Instance.new("IntValue")	
	cash.Name = "Aureus"
	cash.Value = 0
	cash.Parent = ls

	local KillsRequirement = 10

	Kills.Changed:Connect(function()
		if NewValue >= KillsRequirement then
			print(p.Name.." has levelled up! Current Level: ", Level.Value)
			Kills.Value = 0
			Level += 1
			KillsRequirement *= Level.Value
		end

		local crates = game.ReplicatedStorage:WaitForChild("Crates")

		game.ReplicatedStorage.CrateRE.OnServerEvent:Connect(function(plr, crateType, crateTime)
			if crates:FindFirstChild(crateType) then
				local price = crates[crateType].Price.Value
				if plr.leaderstats.Aureus.Value >= price then
					plr.leaderstats.Aureus.Value = plr.leaderstats.Aureus.Value - price

					local unboxableWeapons = crates[crateType]:GetChildren()

					local chosenWeapon 
					repeat chosenWeapon = unboxableWeapons[math.random(#unboxableWeapons)] wait() until chosenWeapon:IsA("Tool")

					game.ReplicatedStorage.CrateRE:FireClient(plr, chosenWeapon)

					wait(crateTime + 1)

					chosenWeapon:Clone().Parent = plr.Backpack
				end
			end
		end)
	end) 
end)

By using this:

Kills.Changed:Connect(function(NewValue)
if NewValue >= KillsRequirement then
print(p.Name…" has levelled up! Current Level: ", Level.Value)
Kills.Value = 0
Level += 1
KillsRequirement *= Level.Value

‘Kills’ and ‘Level’ are underlined blue each time. Also says Unknown global when I hover the mouse over them.

Now only ‘NewValue’ is underlined blue and I have no idea why. The rest is fixed though, so thanks.

im gonna guess the NewValue variable is the kills value

game.Players.PlayerAdded:Connect(function(p)
	local dss = game:GetService("DataStoreService")
	local levelDS = dss:GetDataStore("CrateServer")

	local ls = Instance.new("Folder")
	ls.Name = "leaderstats"
	ls.Parent = p

	local Kills = Instance.new("IntValue")
	Kills.Name = "Kills"
	Kills.Value = 0
	Kills.Parent = ls

	local Level = Instance.new("IntValue")
	Level.Name = "Level"
	Level.Parent = ls

	local cash = Instance.new("IntValue")	
	cash.Name = "Aureus"
	cash.Value = 0
	cash.Parent = ls

	local KillsRequirement = 10

	Kills.Changed:Connect(function()
		local NewValue = Kills.Value
		
		if NewValue >= KillsRequirement then
			print(p.Name.." has levelled up! Current Level: ", Level.Value)
			Kills.Value = 0
			Level += 1
			KillsRequirement *= Level.Value
		end

		local crates = game.ReplicatedStorage:WaitForChild("Crates")

		game.ReplicatedStorage.CrateRE.OnServerEvent:Connect(function(plr, crateType, crateTime)
			if crates:FindFirstChild(crateType) then
				local price = crates[crateType].Price.Value
				if plr.leaderstats.Aureus.Value >= price then
					plr.leaderstats.Aureus.Value = plr.leaderstats.Aureus.Value - price

					local unboxableWeapons = crates[crateType]:GetChildren()

					local chosenWeapon 
					repeat chosenWeapon = unboxableWeapons[math.random(#unboxableWeapons)] wait() until chosenWeapon:IsA("Tool")

					game.ReplicatedStorage.CrateRE:FireClient(plr, chosenWeapon)

					wait(crateTime + 1)

					chosenWeapon:Clone().Parent = plr.Backpack
				end
			end
		end)
	end) 
end)

Marking as solution because it solved the original problem. Unfortunately, while no longer broken as such, when players reach the KillsRequirement, Kills reset to 0 and Level does not increase.

you can just remove this line if you want to fix it

Level still doesn’t rise, but kills stopped resetting.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.