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

Problem with final Ends. Easy fix?

Asked by 9 years ago

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

Log in to vote
3
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

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.

0
Thanks. And yeah, didn't tab this code for whatever reason! :3 Usually I do. Michael007800 144 — 9y
0
However, I still get the wavy line thing under the second to last end stating " ')' expected (to close '(' at line 3) near end " Michael007800 144 — 9y
0
You should keep the parenthesis at the very end, did you remove it by accident? BlueTaslem 18071 — 9y
0
Nope. And the error message does appear after the fix... Michael007800 144 — 9y
0
Messed around (After going to sleep) and yeah, it's fixed. Thx. Michael007800 144 — 9y
Ad

Answer this question