Chat Door Script Help

You can write your topic however you want, but you need to answer these questions:

  1. I want to create a chat door that allows a certain rank in a group to chat “:open” or “:close” to open or close the door. I basically don’t want anyone who is a rank+ to not be able to use the command.

  2. The problem is, it won’t allow me to use :GetRankInGroup to allow only a certain rank and above to use the command. I looked everywhere for a solution, but no luck.

  3. I tried “if player:GetRankInGroup(groupID) >= groupranknumber then” and I placed it in my function, but it stopped making the script work.

door.Anchored = true

function open()
    door.Transparency = 1
    door.CanCollide = false
end

function close()
    door.Transparency = 0
door.CanCollide = true
end

game.Players.PlayerAdded:Connect(function(p)
    p.Chatted:Connect(function(msg)
        local message = msg:lower()
if player:GetRankInGroup(5790488) >= 13 then
        if message == ":open" then
            open()
        end

    if message == ":close" then
        close()
    end
end)
end)

Any errors? Also, try using this code:

door.Anchored = true

function open()
    door.Transparency = 1
    door.CanCollide = false
end

function close()
    door.Transparency = 0
	door.CanCollide = true
end

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        local message = msg:lower()
		if plr:GetRankInGroup(5790488) >= 13 then
        	if message == ":open" then
          	    open()
			elseif message == ":close" then
				close()
			end
    	end
	end)
end)

And the code obviously wouldn’t work cause of these errors:

You randomly used “player”, when it was actually “p”, and “player” is nil.

Error
door.Anchored = true

function open()
    door.Transparency = 1
    door.CanCollide = false
end

function close()
    door.Transparency = 0
door.CanCollide = true
end

game.Players.PlayerAdded:Connect(function(p)
    p.Chatted:Connect(function(msg)
        local message = msg:lower()
if player:GetRankInGroup(5790488) >= 13 then -- This line
        if message == ":open" then
            open()
        end

    if message == ":close" then
        close()
    end
end)
end)

You missed an “end”, at one of the if statements.

Error
door.Anchored = true

function open()
    door.Transparency = 1
    door.CanCollide = false
end

function close()
    door.Transparency = 0
door.CanCollide = true
end

game.Players.PlayerAdded:Connect(function(p)-- 1
    p.Chatted:Connect(function(msg)-- 2
        local message = msg:lower()
if player:GetRankInGroup(5790488) >= 13 then--3
        if message == ":open" then--4
            open()
        end--4

    if message == ":close" then--5, wait, where is the end of my statement?
        close()
    end-- 3
end)-- 2
end)-- 1

Not sure if its an error but.. You could have used an elseif instead of an other if statement.

Error?
door.Anchored = true

function open()
    door.Transparency = 1
    door.CanCollide = false
end

function close()
    door.Transparency = 0
door.CanCollide = true
end

game.Players.PlayerAdded:Connect(function(p)
    p.Chatted:Connect(function(msg)
        local message = msg:lower()
if player:GetRankInGroup(5790488) >= 13 then
        if message == ":open" then
            open()
        end

    if message == ":close" then-- Here.
        close()
    end
end)
end)
1 Like

Fixed the mistakes and even used your code, but it still failed to work.

Hm, did you made the variable of the “door” already?

I think so. It should be there.

Are you able to give the full script?

oor.Anchored = true

function open()
door.Transparency = 1
door.CanCollide = false
end

function close()
door.Transparency = 0
door.CanCollide = true
end

game.Players.PlayerAdded:Connect(function(p)
p.Chatted:Connect(function(msg)
local message = msg:lower()
if p:GetRankInGroup(5790488) >= 13 then
if message == “:open” then
open()
end

if message == ":close" then
    close()

end
end
end)
end)

You didn’t ever reference the “door” as a variable within your code pal.

Tried this code using my own group as a test and it worked for me; obviously the values used for the GetRankInGroup function is different.

local door = script.Parent

function open()
door.Transparency = 1
door.CanCollide = false
end

function close()
door.Transparency = 0
door.CanCollide = true
end

game.Players.PlayerAdded:Connect(function(p)
p.Chatted:Connect(function(msg)
local message = msg:lower()
if message == “:open” and p:GetRankInGroup(5655197) >= 200 then
print(“Opening Door!”)
open()

		elseif message == ":close" and p:GetRankInGroup(5655197) >= 200 then
			print("Closing Door!")
			close()

end
end)
end)

1 Like

It didn’t seem to work for me. No worries though, i will figure it out soon. But thank you!

User lexishh has greatly assited me, and I was finally able to get the door!

2 Likes