if game.Players.LocalPlayer then
local player = game.Players.LocalPlayer
local currency = player:WaitforChild('leaderstats').Money
local amount = 1100
local tool = game.Lighting["AK-47"]
connect (function(plr)
if currency >= amount and not player.Backpack:FindFirstChild('AK-47') or player.Character:FindFirstChild('AK-47') then
currency.Value = currency.Value - amount
local tool = tool:Clone()
tool.Parent = plr.Backpack
end
COMMUNITY QUESTION
Workspace.buy ak47.Script:16: 'end' expected (to close 'function' at line 6) near '<eof>'?
1 answer
Seems like you forgot some ends. But the first if statement is redundant, so you should be good with just adding one to close your attempt at setting up an event on line 6.
And secondly, it seems like you're attempting to connect an event.. but you haven't defined the event that you're connecting. There's no way for me to know what object or event you're trying to connect the function to so you're just gonna have to fix that.
local player = game.Players.LocalPlayer
local currency = player:WaitforChild('leaderstats').Money
local amount = 1100
local tool = game.Lighting["AK-47"]
someobject.someEvent:connect(function(plr) --YOU NEED TO FIX THIS
if currency >= amount and not player.Backpack:FindFirstChild('AK-47') and not player.Character:FindFirstChild('AK-47') then
currency.Value = currency.Value - amount
local tool = tool:Clone()
tool.Parent = plr.Backpack
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
You need an end for your both of your If statements as well as 'end)' for the function.