01 | local gamepass = 16730719 |
02 | local market = game:GetService( "MarketplaceService" ) |
03 | local replicatedStorage = game:GetService( "ReplicatedStorage" ) |
04 |
05 | game.Players.PlayerAdded:Connect( function (player) |
06 | player.CharacterAdded:Connect( function (Character) |
07 | if market:UserOwnsGamePassAsync(player.UserId, gamepass) then |
08 | replicatedStorage.Remotes.Lift.OnServerEvent:Connect( function (player) |
09 | player.leaderstats.Views.Value = player.leaderstats.Views.Value + 2 |
10 | else |
11 | replicatedStorage.Remotes.Lift.OnServerEvent:Connect( function (player) |
12 | player.leaderstats.Views.Value = player.leaderstats.Views.Value + 1 |
13 | end |
14 | end ) |
15 | end |
16 | end ) |
17 | end ) |
there is actually 2 errors error 1: Error: (10,3) Syntax error: Expected 'end' (to close 'function' at line 8), got 'else'
error 2: Error: (14,3) Syntax error: Expected ')' (to close '(' at line 11), got 'end'
The error means the code expected an end to close on the event of OnServerEvent to enclose the function! You didn't add an end with a parenthesis on line 13, and therefore got the error: Expected ')' (to close '(' at line 11), got 'end'
Add the end with an ending parenthesis like this end)
on line 13
01 | local gamepass = 16730719 |
02 | local market = game:GetService( "MarketplaceService" ) |
03 | local replicatedStorage = game:GetService( "ReplicatedStorage" ) |
04 |
05 |
06 | game.Players.PlayerAdded:Connect( function (player) |
07 | player.CharacterAdded:Connect( function (Character) |
08 | if market:UserOwnsGamePassAsync(player.UserId, gamepass) then |
09 | replicatedStorage.Remotes.Lift.OnServerEvent:Connect( function (player) |
10 | player.leaderstats.Views.Value = player.leaderstats.Views.Value + 2 |
11 | end ) |
12 | else |
13 | replicatedStorage.Remotes.Lift.OnServerEvent:Connect( function (player) |
14 | player.leaderstats.Views.Value = player.leaderstats.Views.Value + 1 |
15 | end ) |
16 | end |
17 | end ) |
18 | end ) |
I originally thought you had two too many ends, but it seems that you've nested two listeners.
01 | local gamepass = 16730719 |
02 | local market = game:GetService( "MarketplaceService" ) |
03 | local replicatedStorage = game:GetService( "ReplicatedStorage" ) |
04 |
05 | replicatedStorage.Remotes.Lift.OnServerEvent:Connect( function (player) |
06 | if market:UserOwnsGamePassAsync(player.UserId, gamepass) then |
07 | player.leaderstats.Views.Value = player.leaderstats.Views.Value + 2 |
08 | else |
09 | player.leaderstats.Views.Value = player.leaderstats.Views.Value + 1 |
10 | end |
11 | end ) |
You don't need the PlayerAdded nor the CharacterAdded event as you already get player from the client when firing a RemoveEvent. I do not think you can nest a listener inside an event either.