Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i make a tool be cloned into your backpack when you are in a group?

Is their a way to make it if your rank is a specific number in the group you get a tool when spawned?

Here is the script I attempted to make:

-- Add script into StarterPlayer>StarterPlayerScripts
toolName = ("Glock17") -- EXAMPLE: ("Cyan Mace")
groupId = 6756481 -- Add your group id here.
game.Players.PlayerAdded:connect(function(player)
	if player then
		if player:IsInGroup() then
			local tool1 = game.ReplicatedStorage.Tools:FindFirstChild("Glock17"):Clone()
			local tool2 = game.ReplicatedStorage.Tools:FindFirstChild("Glock17"):Clone()
			tool1.Parent = player.StarterGear
			tool2.Parent = player.Backpack
		end
	end
end)

1 answer

First off, I'd recommend using server-sided scripts instead of local scripts. To do this, insert a script into server script service. Put the following lines of code inside the script:

toolName = ("Glock17")
groupId = 6756481
game.Players.PlayerAdded:connect(function(player)
    if player then
        if player:IsInGroup(groupId) then
            local tool1 = game.ReplicatedStorage.Tools:FindFirstChild("Glock17"):Clone()
            local tool2 = game.ReplicatedStorage.Tools:FindFirstChild("Glock17"):Clone()
            tool1.Parent = player.StarterGear
            tool2.Parent = player.Backpack
        end
    end
end)

At the time all that I see that you did wrong was forget to put groupId inside of when you were checking if the player was in a group, and of course using a local script instead of a server script.

If you have any more questions feel free to ask!

3 comments

0

How would I make this correlate to group rank?

0

If you'd like to make it group rank locked, change the if player is in group to **if player:GetRankInGroup(groupId) >= YOUR GROUP RANK HERE

0

Unfortunately this does not work.

This discussion is preserved as it was. New answers, comments, and votes are closed.