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

A loophole error saying I need to put ) symbol. Help?

Title says it all. There's a loophole in my script where if I put ')' it says i need to put a 'end' but if a put a 'end' it says I need to put a ')'. HELP!

https://imgur.com/a/Cm04BOQ <---------- script

1 comment

0

You are missing "then". The syntax for if statements is "if condition then statements end"

2 answers

In the future, could you post the code instead of a screenshot?

I think the issue is that each if statement needs their own ends. That and you only need one character added event, not three.

If you were doing an if/else-if statement, you could get away with using only one end, but since you have three separate if statements, you'll need three ends one for each if statement.

Code should be formatted like this:

the if SOME CONDITION are your if statements that check if the player owns the gamepasses, but I was a bit lazy to type them out since you didn't provide code.

--Maybe consider naming these variable something like CoilGamepassId, TeleportGamepassId and GemGamepassId since I assume they're ids for the gamepasses? 
local id = 7864090
local id2 = 7864085
local id3 = 7864132

--Consider naming these variables gravityCoil, teleportTool, and donatorGem?
local item1 = script:WaitForChild("Gravity Coil")
local item2 = script:WaitForChild("Teleport Tool")
local item3 = script:WaitForChild("Donator Gem")

 
local MarketPlaceService = game:GetService("MarketplaceService")

--player added function which lets us run the character added function: 
game.Players.PlayerAdded:Connect(function(player)
	--whenever the player's character loads into the game, check if they have the gamepasses:
	player.CharacterAdded:Connect(function()
		if SOME CONDITION #1 then
			--DO SOMETHING WHEN THIS CONDITION IS MET!!
		end
		
		if SOME CONDITION #2 then
			--DO SOMETHING WHEN THIS CONDITION IS MET!!
		end

		if SOME CONDITION #3 then
			--DO SOMETHING WHEN THIS CONDITION IS MET!!
		end
	end)
end)

You're missing a lot of **end)**s. Like, a lot. Plus, you're using a lot of functions instead of a single one. Replace the other functions with the magic of else if.

Here's what you should do:

local id = 7864090 -- Name them something, not just ID.
local id2 = 7864085
local id3 = 7864132

local item1 = script:WaitForChild("Gravity Coil") -- Same here. Something like g_coil.
local item2 = script:WaitForChild("Teleport Tool")
local item3 = script:WaitForChild("Donator Gem")


local MarketPlaceService = game:GetService("MarketplaceService")


game.Players.PlayerAdded:Connect(function(player) -- PlayerAdded

	player.CharacterAdded:Connect(function()

		if MarketPlaceService:UserOwnsGamepassAsync(player.UserId, id) then
			item1:Clone().Parent = player.Backpack	

		else if MarketPlaceService:UserOwnsGamepassAsync(player.UserId, id2) then
			item2:Clone().Parent = player.Backpack
	
		else if MarketPlaceService:UserOwnsGamepassAsync(player.UserId, id2) then
			item2:Clone().Parent = player.Backpack

		else if MarketPlaceService:UserOwnsGamepassAsync(player.UserId, id3) then
			item3:Clone().Parent = player.Backpack

		else
			print("Player "..player.." has no game passes gang up on him")
		end
	end)
end)

This is organized, (well kinda) and this goes into a SCRIPT but you probably know that.

P.S. No screenshots, post code screenshots are really annoying. Plus, you should use select that link and use link from ScriptingHelpers. What's the point of adding that if nobody uses it?

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