Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)



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

This discussion is preserved as it was. New answers, comments, and votes are closed.