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

Workspace.buy ak47.Script:16: 'end' expected (to close 'function' at line 6) near '<eof>'? [closed]

Asked by
FedrixYT -21
7 years ago
Edited 7 years ago
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
0
You need an end for your both of your If statements as well as 'end)' for the function. GuestRealization 102 — 7y

Closed as Non-Descriptive by Goulstem

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago

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)
Ad