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

Am I doing this wrong?

local group = {
	["jameswowsmile"] = true;
	["leslielol1234"] = true;
}
 
game.Players.PlayerAdded:connect(function(player)
	if group[player.Name] then 
		player.Chatted:connect(function(msg)
			--chatted code 
		end)
	end
end)


door = script.Parent --this is the door 

function onChatted(msg, recipient, speaker) 

-- convert to all lower case 

local source = string.lower(speaker.Name) 
msg = string.lower(msg) 

if (msg == "FloorClose") then 
door.CanCollide = false 
door.Transparency = 1

end 

end 

function onPlayerEntered(newPlayer) 
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) 
end 

game.Players.ChildAdded:connect(onPlayerEntered) 

This is supposed to give two players (Jameswowsmile and Leslielol1234) permission to say a command that would make a floor disappear when you say "FloorClose". I tested this and it didn't work. What did I do wrong?

1 answer

✓ Accepted answer

#Problems

  1. You need to add the chatted door thing inside the chatted thing
  2. You are comparing a lowercase to an uppercase(lowercase all the letters in FloorClose)

#Final Product

local group = {
    ["jameswowsmile"] = true;
    ["leslielol1234"] = true;
}

game.Players.PlayerAdded:connect(function(player)
    if group[player.Name] then 
        player.Chatted:connect(function(msg)
            door = script.Parent
		if msg:lower() == "floorclose" then --LowerCased "FloorClosed"
			door.CanCollide = false 
			door.Transparency = 1
		end
        end)
    end
end)


Hope it helps!

1 comment

0

Thank you! It works! However, on the 9th line, you forgot a local. Works after you put it on!

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