I'm making a Roblox game and need to have a give system for it. I have this but its for players not group and rank.
game.Players.PlayerAdded:connect(function(plyr) if plyr == "mikejr5666667" then plyr.Chatted:connect(function(chatmessage) local command = {} _, _, filter, receiver, gift = string.find(chatmessage, "(give/)(%w*/)(%w*)") table.insert(command, filter); table.insert(command, receiver); table.insert(command, gift) if #command == 3 and command[1] == "give/" then local player = command[2]:sub(1, (command[2]:len() - 1)) local tool = command[3] if game.Players:FindFirstChild(player) and game.Lighting:FindFirstChild(tool) then game.Lighting[tool]:Clone().Parent = game.Players[player].Backpack end end end) end end)
Try my solution!
local groupId = 0000000 -- Change this to your group's ID local rankForGiveAccess = 255 -- Change this to the rank number local function playerCanUseGiveCommands(player) return player:GetRankInGroup(groupId) >= rankForGiveAccess end game.Players.PlayerAdded:connect(function(plyr) if playerCanUseGiveCommands(plyr) then plyr.Chatted:connect(function(chatmessage) local command = {} _, _, filter, receiver, gift = string.find(chatmessage, "(give/)(%w<em>/)(%w</em>)") table.insert(command, filter) table.insert(command, receiver) table.insert(command, gift) if #command == 3 and command[1] == "give/" then local player = command[2]:sub(1, (command[2]:len() - 1)) local tool = command[3] if game.Players:FindFirstChild(player) and game.Lighting:FindFirstChild(tool) then game.Lighting[tool]:Clone().Parent = game.Players[player].Backpack end end end) end end)
From line 08
on, it's basically your original code, but formatted.