I was making a command that if you say !training it moves my training equipment from ServerStorage to Workspace.
However, I want it that only I can do it, or maybe other players in a table.
But, I suck with tables, and I need help.
local prefix = "!"
local admins = "AmariGXL"
-- if chat message by admins is !training then move model from serverstorage to workspace
game:GetService("Players").PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if message == prefix.."training" and admins then
local model = game.ServerStorage["Training Gear"] -- change ModelName to the name of your model in ServerStorage
model.Parent = workspace
end
end)
end)
The script works just fine, but it has it that anybody can do it, now i just but “admins” but that obviously doesn’t work.
local prefix = "!"
local admins = {"AmariGXL", "Roblox"} -- Converted to a table, "Roblox" can be replaced with a different username
-- if chat message by admins is !training then move model from serverstorage to workspace
game:GetService("Players").PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if message == prefix.."training" and table.find(admins, player.Name) then
local model = game.ServerStorage["Training Gear"] -- change ModelName to the name of your model in ServerStorage
model.Parent = workspace
end
end)
end)
Realistically you should be using UserIDs for security reasons, for example if you changed your username and someone took the old username, they could gain free admin if you forget to change it here.