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

What is wrong with the end) in line 5?

I dont know how to fix this but i know it is in line 5

local cV = Instance.new("IntValue")
cV.Name = "clickedValue"
cV.Parent = plr.PlayerGui
cV.Value = 1
end)

script.Parent.MouseClick:connect(function(plr)

local pCV = plr:FindFirstChild("clickedValue")
local pLS = plr:FindFirstChild("leaderstats")
local pP = pLS:FindFirstChild("Points")
local price = 10

if pP < price then 
pCV = pCV + 1
end
end)

2 answers

Remove the end) at the top of you're script you only need those after you use an anonymous function also plr isn't defined so you need to do something like plr = game.Players.LocalPlayer make sure you put the script in a local script. The code should look like this

I would help more but i am not sure how you have everything set up so this is as much as i can do

-- you're script i just indented this
local cV = Instance.new("IntValue")
cV.Name = "clickedValue"
cV.Parent = plr.PlayerGui
cV.Value = 1
end)

script.Parent.MouseClick:connect(function(plr)
	local pCV = plr:FindFirstChild("clickedValue")
	local pLS = plr:FindFirstChild("leaderstats")
	local pP = pLS:FindFirstChild("Points")
	local price = 10
	if pP < price then 
		pCV = pCV + 1
	end
end)
--edited script
local cV = Instance.new("IntValue")
cV.Name = "clickedValue"
plr = game.Players.LocalPlayer
cV.Parent = plr.PlayerGui
cV.Value = 1

script.Parent.MouseClick:connect(function(plr)
	local pCV = plr:FindFirstChild("clickedValue")
	local pLS = plr:FindFirstChild("leaderstats")
	local pP = pLS:FindFirstChild("Points")
	local price = 10
	if pP < price then 
		pCV = pCV + 1
	end
end)

1 comment

0

Correct, the player has to be defined for the top area, although in the MouseClick function, plr is a correct parameter.

Remove the end)

You didn't start a function so it doesn't need an end. This would do it:

local cV = Instance.new("IntValue")
cV.Name = "clickedValue"
cV.Parent = plr.PlayerGui
cV.Value = 1	 

script.Parent.MouseClick:connect(function(plr)
local pCV = plr:FindFirstChild("clickedValue")
local pLS = plr:FindFirstChild("leaderstats")
local pP = pLS:FindFirstChild("Points")
local price = 10
	 
if pP < price then
pCV = pCV + 1
end
end)

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