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

Expected 'end' (to close 'function' at line 12), got <eof>?

Asked by 4 years ago

Hey, im trying to fix this error in my script and i cannot find it, please help me

local RS = game:GetService("ReplicatedStorage")
local function createEvent(eventName)
        local event = game.ReplicatedStorage:FindFirstChild(eventName)
    if not event then
            event = Instance.new("RemoteEvent", game.ReplicatedStorage)
            event.Name = eventName
        end
        return event
    end

    local buy= createEvent("BuyGCoil")
    buy.OnServerEvent:Connect(function(player, price)
    local points = player:FindFirstChild("leaderstats"):FindFirstChild("Points")
     local item =  RS:WaitForChild("Gravity Coil")
        points.Value = points.Value - price
    local clone = item:Clone()
    local SPclone = item:Clone()
    clone.Parent = player.Backpack
    SPclone.Parent = player.StarterGear
1
I don't see an end) at the end of the script to close the function. killerbrenden 1537 — 4y
0
I actually tried that before and it didnt work, now it does, please put that as an answer so i can give you reputation Shadic1270 136 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
local RS = game:GetService("ReplicatedStorage")
local function createEvent(eventName)
        local event = game.ReplicatedStorage:FindFirstChild(eventName)
    if not event then
            event = Instance.new("RemoteEvent", game.ReplicatedStorage)
            event.Name = eventName
        end
        return event
    end

    local buy= createEvent("BuyGCoil")
    buy.OnServerEvent:Connect(function(player, price)
    local points = player:FindFirstChild("leaderstats"):FindFirstChild("Points")
     local item =  RS:WaitForChild("Gravity Coil")
        points.Value = points.Value - price
    local clone = item:Clone()
    local SPclone = item:Clone()
    clone.Parent = player.Backpack
    SPclone.Parent = player.StarterGear
end) --// This

You forgot to close the function with an end)

Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

When you have a function with a remote event as you have above, buy.OnServerEvent:Connect(function(player,price) there should be an end at the end of the remote event, because it's technically a function now. Try this:

buy.OnServerEvent:Connect(function(player, price)
    local points = player:FindFirstChild("leaderstats"):FindFirstChild("Points")
    local item =  RS:WaitForChild("Gravity Coil")
    points.Value = points.Value - price
    local clone = item:Clone()
    local SPclone = item:Clone()
    clone.Parent = player.Backpack
    SPclone.Parent = player.StarterGear
end)

Hope this helped and happy coding!

Answer this question