I would like this command to only work if it is spoken by a specific team member. Any help is much appreciated
Script--
local message = "[opencombatdoor]" local door = script.Parent function onChatted(msg, recipient, speaker) local source = string.lower(speaker.Name) msg = string.lower(msg) if (msg == message) then door.CanCollide = false for i = 1, 9 do door.Transparency = door.Transparency + 0.1 wait() end wait(10) for i = 1, 9 do door.Transparency = door.Transparency - 0.1 wait() end door.CanCollide = true end end function onPlayerEntered(newPlayer) newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) end game.Players.PlayerAdded:connect(onPlayerEntered)
You would most likely be looking for a conditional debounce at the top of your function. This statement is using the .Team
property of Player
, which is viewed as speaker
through the argument given by the Chatted
signal. All that information should be used like so:
function onChatted(msg, recipient, speaker) if (speaker.Team ~= "Insert Team name here") then return end end
It is also advised that you use Connect
instead.