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

This gate has an error, so how do i fix it?

I added a loop and fixed the Chatted event and now the "end)" has a red line under it...

local gate = script.Parent

Game.Players.PlayerAdded:connect(function(plr)
	if plr.Chatted:connect(function(msg)
		if msg == "Open Lobby" then
		if plr:GetRankInGroup(947529) >= 5 then
			if gate.Position == Vector3(-2.7, 10.19, -0.3)then
				for i=1, 22 do
    			gate.Position = gate.Position - Vector3.new(0, 0.4, 0)
    			wait(0.1)
				gate.Position = gate.Position + Vector3.new(0,.2,0)
					end
				end
			end
		end
	end
end)

local gate = script.Parent

Game.Players.PlayerAdded:connect(function(plr)
	if plr.Chatted:connect(function(msg)
		if msg == "Close Lobby" then
		if plr:GetRankInGroup(947529) >= 3 then
			if gate.Position == Vector3(-2.7, 28.19, -0.3)then
				for i=1, 22 do 
    			gate.Position = gate.Position - Vector3.new(0, 0.4, 0)
   				 wait(0.1)
				gate.Position = gate.Position + Vector3.new(0,.2,0)
				wait(.1)
					end
				end
			end
		end
	end
end)

2 answers

✓ Accepted answer

You added 'if" in front of plr.Chatted:connect(function(msg) with out 'then' after it, but those arnt necessary so I removed them. Second, you forgot to close you second function by adding an ')' after end. Hope this works, good luck!

local gate = script.Parent

Game.Players.PlayerAdded:connect(function(plr)
     plr.Chatted:connect(function(msg)
        if msg == "Open Lobby" then
        	if plr:GetRankInGroup(947529) >= 5 then
            	if gate.Position == Vector3(-2.7, 10.19, -0.3)then
                	for i=1, 22 do
                		gate.Position = gate.Position - Vector3.new(0, 0.4, 0)
                	wait(0.1)
                		gate.Position = gate.Position + Vector3.new(0,.2,0)
                    end
                end
            end
        end
    end)
end)

local gate = script.Parent

Game.Players.PlayerAdded:connect(function(plr)
    plr.Chatted:connect(function(msg)
        if msg == "Close Lobby" then
        	if plr:GetRankInGroup(947529) >= 3 then
            	if gate.Position == Vector3(-2.7, 28.19, -0.3)then
                	for i=1, 22 do 
                		gate.Position = gate.Position - Vector3.new(0, 0.4, 0)
                 	wait(0.1)
               			gate.Position = gate.Position + Vector3.new(0,.2,0)
                		wait(.1)
                    end
                end
            end
        end
    end)
end)

local gate = script.Parent

Game.Players.PlayerAdded:connect(function(plr)
	plr.Chatted:connect(function(msg) -- WHY do you not lower the message? they will have to say EXACTLY that, with caps, for it to work.
		if msg == "Close Lobby" then
			if plr:GetRankInGroup(947529) >= 3 then
				if gate.Position == Vector3(-2.7, 28.19, -0.3) then -- WHY? Dude add a variable if it tells you open or closed, you can't guarantee it will be in that exact spot
					for i=1, 22 do 
						gate.Position = gate.Position - Vector3.new(0, 0.4, 0)
						wait(0.1)
						gate.Position = gate.Position + Vector3.new(0,.2,0)
						wait(.1)
					end
				end
			end
		elseif msg == "Open Lobby" then
			if plr:GetRankInGroup(947529) >= 5 then
				if gate.Position == Vector3(-2.7, 10.19, -0.3) then
			                for i=1, 22 do
				                gate.Position = gate.Position - Vector3.new(0, 0.4, 0)
				                wait(0.1)
				                gate.Position = gate.Position + Vector3.new(0,.2,0)
					end
				end	
			end
		end
	end)
end)

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