Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

What is wrong with the end) in line 5?

Asked by 9 years ago

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

Log in to vote
3
Answered by
Damo999 182
9 years ago

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)
0
Correct, the player has to be defined for the top area, although in the MouseClick function, plr is a correct parameter. RaverKiller 668 — 9y
Ad
Log in to vote
1
Answered by 9 years ago

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)

Answer this question