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

expected <eof> got 'else'. any help?

Asked by 2 years ago
local gamepass = 16789429
local market = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(Character)
        if market:UserOwnsGamePassAsync(player.UserId, gamepass) then
            local replicatedStorage = game:GetService("ReplicatedStorage")
            replicatedStorage.Remotes.Lift.OnServerEvent:Connect(function(player)
                player.leaderstats.Views.Value = player.leaderstats.Views.Value + 2
            end)

            replicatedStorage.Remotes.Lift2.OnServerEvent:Connect(function(player)
                player.leaderstats.Views.Value = player.leaderstats.Views.Value + 4
            end)
        end
    end)
end)

else 
    print("haha poor, u dont have gamepass")
    local replicatedStorage = game:GetService("ReplicatedStorage")

    replicatedStorage.Remotes.Lift.OnServerEvent:Connect(function(player)
        player.leaderstats.Views.Value = player.leaderstats.Views.Value + 1
    end)

    replicatedStorage.Remotes.Lift2.OnServerEvent:Connect(function(player)
        player.leaderstats.Views.Value = player.leaderstats.Views.Value + 2
    end)
end)

Dont mind the print i was bored and needed to see where the script failed

2 answers

Log in to vote
1
Answered by 2 years ago
Edited 2 years ago
local gamepass = 16789429
local market = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(Character)
        if market:UserOwnsGamePassAsync(player.UserId, gamepass) then
            local replicatedStorage = game:GetService("ReplicatedStorage")
            replicatedStorage.Remotes.Lift.OnServerEvent:Connect(function(player)
                player.leaderstats.Views.Value = player.leaderstats.Views.Value + 2
            end)

                    replicatedStorage.Remotes.Lift2.OnServerEvent:Connect(function(player)
                player.leaderstats.Views.Value = player.leaderstats.Views.Value + 4
            end)
        else -- they dont own the gamepass (need to keep inside everything)
            print("haha poor, u dont have gamepass")
            local replicatedStorage = game:GetService("ReplicatedStorage")

            replicatedStorage.Remotes.Lift.OnServerEvent:Connect(function(player)
                player.leaderstats.Views.Value = player.leaderstats.Views.Value + 1
            end)

            replicatedStorage.Remotes.Lift2.OnServerEvent:Connect(function(player)
                player.leaderstats.Views.Value = player.leaderstats.Views.Value + 2
            end)
        end
    end)
end)



Ad
Log in to vote
1
Answered by 2 years ago

You're putting the "else" statement outside the function where you call the "if" statement.....not valid. Put lines 19 and 30 in between 14 and 15

Answer this question