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

? | Expected ')' (to close '(' at line x), got 'end'

Error: Workspace.Leaderboard:22: Expected ')' (to close '(' at line 13), got 'end'

Code:

local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
	local Leaderstats = Instance.new("Folder")
	Leaderstats.Name = "leaderstats"
	Leaderstats.Parent = Player
	local Stage = Instance.new("IntValue")
	Stage.Name = "Stage"
	Stage.Value = 0
	local function SaveCurrentStage(ply)
	Stage.Value = StageDataStore:SetAsync(tostring(ply.UserId), ply.leaderstats.Stage.Value)
	Stage.Value = 0 
	Stage.Parent = Leaderstats
	Player.CharacterAdded:Connect(function(Characer)
		local Leaderstats = Player:FindFirstChild("leaderstats")
		if (Leaderstats and Leaderstats.Stage) then
			local Stage = workspace:FindFirstChild(tostring(Stage.Value))
			if (Stage) then
				Player.Character:MoveTo(Stage.Position + Vector3.new(0,3,0))
			end
		end
	end
end


Thanks.

1 answer

✓ Accepted answer

Al least, I deserve an upvote for this. This is how your code must be looking. Next time, please use Lua block code instead of Inline code.

local Players = game:GetService("Players") 

Players.PlayerAdded:Connect(function(Player) 
	local Leaderstats = Instance.new("Folder") 
	Leaderstats.Name = "leaderstats" 
	Leaderstats.Parent = Player 
	local Stage = Instance.new("IntValue") 
	Stage.Name = "Stage" 
	Stage.Value = 0 

	local function SaveCurrentStage(ply) 
		Stage.Value = StageDataStore:SetAsync(tostring(ply.UserId), ply.leaderstats.Stage.Value) 
		Stage.Value = 0 
		Stage.Parent = Leaderstats 

		Player.CharacterAdded:Connect(function(Characer) 
			local Leaderstats = Player:FindFirstChild("leaderstats") 
			if (Leaderstats and Leaderstats.Stage) then 
				local Stage = workspace:FindFirstChild(tostring(Stage.Value)) 
				if (Stage) then 
					Player.Character:MoveTo(Stage.Position + Vector3.new(0,3,0)) 
				end 
			end 
		end 
end)

Well, there are several issues. I fixed it in next lines.

local Players = game:GetService("Players") 

Players.PlayerAdded:Connect(function(Player) 
	local Leaderstats = Instance.new("Folder") 
	Leaderstats.Name = "leaderstats" 
	Leaderstats.Parent = Player 
	local Stage = Instance.new("IntValue") 
	Stage.Name = "Stage" 
	Stage.Value = 0 

	local function SaveCurrentStage(ply) 
		Stage.Value = StageDataStore:SetAsync(tostring(ply.UserId), ply.leaderstats.Stage.Value) 
		Stage.Value = 0 
		Stage.Parent = Leaderstats
	end -- End for the function

	Player.CharacterAdded:Connect(function(Characer) 
		local Leaderstats = Player:FindFirstChild("leaderstats") 
		if (Leaderstats and Leaderstats.Stage) then 
			local Stage = workspace:FindFirstChild(tostring(Stage.Value)) 
			if (Stage) then 
				Player.Character:MoveTo(Stage.Position + Vector3.new(0,3,0)) 
			end 
		end 
	end)  -- End) for the CharacterAdded function
end)

Lemme now if it helps!

3 comments

0

Well, I suppose you have the code to trigger your SaveCurrentStage function

0

weird, I could not see the answer. Sorry, I'm new here :). I thought in a bit for what this LUA button is doing, just pasted the code in the wrong place.

0

Thank you so much. It works without any error ????????????????????????

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