Ad
Log in to vote
0

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

Asked by 1 month 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 1 month ago
Edited 1 month 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 1 month 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