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

Problem with final Ends. Easy fix?

I am making a script so that if you own a gamepass, the script removes one of the Gears. If you do not, then it removes the other. However, all I get is on one of the ends, theres meant to be a ) to close line 3, which is put at the end. Is this an easy fix?

local passid = 0000000000
local GamePassService = Game:GetService('GamePassService')
game.Players.PlayerAdded:connect(function(player)
repeat wait(0.1) until player.Backpack	
repeat wait(0.1) until player.StarterGear
if GamePassService:PlayerHasPass(player, passid) then
script.Parent.RobloxPhoneSmartphone:Remove()
else
script.Parent["RobloxPhone Mobile"]:Remove()
end
end
end
end)

1 answer

✓ Accepted answer

Tab your code!

local passid = 0000000000
local GamePassService = Game:GetService('GamePassService')
game.Players.PlayerAdded:connect(function(player)
	repeat wait(0.1) until player.Backpack  
	repeat wait(0.1) until player.StarterGear
	if GamePassService:PlayerHasPass(player, passid) then
		script.Parent.RobloxPhoneSmartphone:Remove()
	else
		script.Parent["RobloxPhone Mobile"]:Remove()
	end
end
end
end)

Look at the last two lines! You have two ends which are already at the far left. You only needed 1) for the if and 2) for the function.


Your repeat loops are not accomplishing anything. In the event that player.Backpack or player.StarterGear hasn't loaded, it will just error because you are accessing a child that hasn't loaded.

Use the :WaitForChild method instead.

5 comments

0

Thanks. And yeah, didn't tab this code for whatever reason! :3 Usually I do.

0

However, I still get the wavy line thing under the second to last end stating " ')' expected (to close '(' at line 3) near end "

0

You should keep the parenthesis at the very end, did you remove it by accident?

0

Nope. And the error message does appear after the fix...

0

Messed around (After going to sleep) and yeah, it's fixed. Thx.

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