I am currently engaged in the development of a Training Center, a project that is still under construction. I am facing a specific challenge related to a door mechanism. My goal is to enable the door to open and close in response to a specific command, but only when I am part of the host team.
Regrettably, my attempts at scripting this functionality have not been successful. Despite my efforts, the scripts I have implemented either do not function as intended or encounter scripting errors.
Objective: I aim to create a system where both doors automatically open when a specific command is executed within the context of the host team.
I kindly seek assistance from anyone proficient in scripting. For your reference, images of both doors are provided below. Your support in resolving this matter would be immensely valued.
You can do this quite easily with RemoteEvents, if the player is in game and they for example press a Button on a Gui for the door to open, you can send a remote event to the server and only open it if the player has a specific permission level, which is either determined by some internal system or possibly Roblox Groups.
Could you provide more information on what the door needs to do (eg. Smoothly open the door) and what a command is (eg. typing “/OpenDoor” in chat)
I think your trying to get the door to open by typing in chat while on the Host team
Here’s what I got:
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local TeamName = "Host"-- Set to the team name
local Prefix = "/"-- Set to what ever you want
local Commands = {}
function Commands.opendoor()-- Change "opendoor" to what ever the command needs to be
--Code to open the door
end
local function IsPlayerOnTeam(Player)-- Find the player on the team
for i,v in Teams:GetTeams()[TeamName]:GetPlayers() do-- Loop
if v == Player then return true end-- Yay we found the player
end
return
end
Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)-- When a player chats
if not IsPlayerOnTeam(Player) then return end-- If they are alowed to send commands
Message = string.lower(Message)
Message = string.split(Message, Prefix)
local FindCommand = Commands[Message[2]]-- Find the command
if FindCommand then
FindCommand()-- Run the command
end
end)
end)