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 5 years ago

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

01local RS = game:GetService("ReplicatedStorage")
02local function createEvent(eventName)
03        local event = game.ReplicatedStorage:FindFirstChild(eventName)
04    if not event then
05            event = Instance.new("RemoteEvent", game.ReplicatedStorage)
06            event.Name = eventName
07        end
08        return event
09    end
10 
11    local buy= createEvent("BuyGCoil")
12    buy.OnServerEvent:Connect(function(player, price)
13    local points = player:FindFirstChild("leaderstats"):FindFirstChild("Points")
14     local item =  RS:WaitForChild("Gravity Coil")
15        points.Value = points.Value - price
16    local clone = item:Clone()
17    local SPclone = item:Clone()
18    clone.Parent = player.Backpack
19    SPclone.Parent = player.StarterGear
1
I don't see an end) at the end of the script to close the function. killerbrenden 1537 — 5y
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 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
01local RS = game:GetService("ReplicatedStorage")
02local function createEvent(eventName)
03        local event = game.ReplicatedStorage:FindFirstChild(eventName)
04    if not event then
05            event = Instance.new("RemoteEvent", game.ReplicatedStorage)
06            event.Name = eventName
07        end
08        return event
09    end
10 
11    local buy= createEvent("BuyGCoil")
12    buy.OnServerEvent:Connect(function(player, price)
13    local points = player:FindFirstChild("leaderstats"):FindFirstChild("Points")
14     local item =  RS:WaitForChild("Gravity Coil")
15        points.Value = points.Value - price
16    local clone = item:Clone()
17    local SPclone = item:Clone()
18    clone.Parent = player.Backpack
19    SPclone.Parent = player.StarterGear
20end) --// This

You forgot to close the function with an end)

Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 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:

1buy.OnServerEvent:Connect(function(player, price)
2    local points = player:FindFirstChild("leaderstats"):FindFirstChild("Points")
3    local item =  RS:WaitForChild("Gravity Coil")
4    points.Value = points.Value - price
5    local clone = item:Clone()
6    local SPclone = item:Clone()
7    clone.Parent = player.Backpack
8    SPclone.Parent = player.StarterGear
9end)

Hope this helped and happy coding!

Answer this question