Solved - Script

So I put in the script for bellow but it didn’t work I’m confused cause the output didn’t say anything about errors but then again the script isn’t working. What could be the problem?

local Opened = false
local Door = game.Workspace.Door
local OpenCmd = "!Open"
local CloseCmd = "!Close"
local CatchAll = require(4710901436)

function onChatted(chat, recipient, speaker)
	local Allowed = {"QufioixDev", "Yohenara"}
	local lowered = chat:lower()

	if chat == OpenCmd and Opened == false and table.find(Allowed, speaker) then -- Open Command
		Door.Transparency = 0.9
		wait(0.2)
		Door.Transparency = 1
		wait(0.1)
		Door.CanCollide = false
		Opened = true
	end

	if chat == CloseCmd and Opened == true and table.find(Allowed, speaker) then -- Close Command
		wait(0.2)
		Door.Transparency = 0.9
		wait(0.1)
		Door.Transparency = 1
		Door.CanCollide = true
		Opened = false
	end
end

CatchAll(function(plr)
	plr.Chatted:Connect(function(chat, recipient) 
		onChatted(chat, recipient, plr) 
	end)
end)```
3 Likes

You’re using

chat:lower()

whereas your open and close commands aren’t in all lowercase. You can solve this issue by getting rid of the capitalization in !Open and !Close.

If you didn’t know already, using chat:lower() will change all of the letters in your string to lowercase letters.

I’ve fixed the open and closed still not working check the output nothing either…

Did you change

to

local OpenCmd = "!open"
local CloseCmd = "!close"

?


Also, what type of script are you using and where is it located?

Yeah I already did that nothing happend still I’m confused because the script looks fine ._.

I bet it has something to do with the module you’re using.

oh wait a second here, I believe I know the issue.

If lower isn’t working, try using

string:len():lower()

or you could use

if chat:match("!Open") then

end

``

It’s time to hunt bugs!
Put print()s everywhere to see what code runs and what doesn’t!
Remove conditions in ifs that aren’t needed!

if chat == CloseCmd and Opened == true and table.find(Allowed, speaker) then

If you think the chat command is what’s not working, then just cut off everything that doesn’t have to do with the chat command.

if chat == CloseCmd then

Repeat with everything else in those ifs!

I’ll spoil it for you—
Are you sure you can table.find(Allowed, speaker)?
Because speaker is a player object, but Allowed is a table of names, not players.
You should be finding the speaker’s name, not the speaker itself.

Also note that you are comparing to chat instead of lowered

I see… I’ll take a quick shot at it see if it works so I can solve this.

So I saw you’re message about the the speaker so I tried changing it up I don’t like perm tables lol but this is what I got. I also got some errors saying some lines weren’t closed so if you can see what’s wrong with this

local Opened = false
local Door = game.Workspace.Door -- Insert location of it
local OpenCmd = "!open"
local CloseCmd = "!close"
local CatchAll = require(4710901436)
local lowered = chat:lower()

function onChatted(chat, recipient, speaker)
	local Allowed = game.Players.PlayerAdded:Connect(function(player)
		if 	{"KaiThePatient", "QufioixDev", "Yohenara"} then
			
		
	if chat == OpenCmd and Opened == false and table.find(Allowed, speaker, player) then -- Open Command
		Door.Transparency = 0.9
		wait(0.2)
		Door.Transparency = 1
		wait(0.1)
		Door.CanCollide = false
		Opened = true
	end

	if chat == CloseCmd and Opened == true and table.find(Allowed, speaker, player) then -- Close Command
		wait(0.2)
		Door.Transparency = 0.9
		wait(0.1)
		Door.Transparency = 1
		Door.CanCollide = true
		Opened = false
	end
end

CatchAll(function(plr)
	plr.Chatted:Connect(function(chat, recipient)
		onChatted(chat, recipient, plr) 
	end)
end)

Ok so you had a few things wrong on the top script the bottom one you messed up even more stuff
here is the top script fixed below
You had the if chat == CloseCmd and the OpenCmd comparing a partial upercased string value from !Open and !Close those shoud both have been all lower as stated above
also on the table.find you where trying to find the speaker(which is the player object) in a table full of string names of the players allowed – to fix this just use the players name not the object by using speaker.Name

I am not sure what the CatchAll module you have is but you could use playeradded which maybe better in this case than that module to declare your player chatted. it in any case I put a print to see if it even sets it all up so if you don’t see the print change to player added

local Opened
local Door = game.Workspace.Door
local OpenCmd = "!open"  -- lowered
local CloseCmd = "!close"  -- lowered
local CatchAll = require(4710901436)  -- not sure what this is...
local Allowed = {'KaiThePatient',"QufioixDev", "Yohenara",'Nyonic'}  -- keep the table here for allowing

function onChatted(chat, recipient, speaker)

	local lowered = string.lower(chat)

	if lowered == OpenCmd and not Opened and table.find(Allowed, speaker.Name) then -- Open Command   -- you have to use lowered and compare it to all lowered OpenCmd and also use speaker.Name to get the players name to match the string in your allow table  -- else with just speaker you are trying to find the player object in the allow
		Door.Transparency = 0.9
		wait(0.2)
		Door.Transparency = 1
		wait(0.1)
		Door.CanCollide = false
		Opened = true
	end

	if lowered == CloseCmd and Opened and table.find(Allowed, speaker.Name) then -- Close Command  -- same here have to use name value to find in table not the player iteself as speaker
		wait(0.2)
		Door.Transparency = 0.9
		wait(0.1)
		Door.Transparency = 1
		Door.CanCollide = true
		Opened = false
	end
end

CatchAll(function(plr)   -- may need to change this to players.PlayerAdded
	plr.Chatted:Connect(function(chat, recipient) 
		onChatted(chat, recipient, plr) 
		print('Chat Catch Setup')  -- print to make sure it setup not sure what the module is
	end)
end)

Thanks a lot @Nyonic was dealing with this problem for a while I knew what you were talking about the lower the strings were already lower cased. I would’ve done Speaker.Name but I went for something else anyways thanks for the help I’ll make this as solved.

1 Like