Hey, im trying to fix this error in my script and i cannot find it, please help me
01 | local RS = game:GetService( "ReplicatedStorage" ) |
02 | local 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 |
01 | local RS = game:GetService( "ReplicatedStorage" ) |
02 | local 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 |
20 | end ) --// This |
You forgot to close the function with an end)
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:
1 | buy.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 |
9 | end ) |
Hope this helped and happy coding!