Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make a :give command for group members above a certain rank?

Asked by 7 years ago
Edited by M39a9am3R 7 years ago

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)
0
If you can script that you should know how to make it into a group thing DevingDev 346 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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.

0
Thanks will try it. Tycoondude45 -5 — 7y
Ad

Answer this question