So I would like to know how to make different group ranks get tools. Some ranks have the same tools. I tried multiple scripts but none of them worked. Anyone can help me please?
Use this when a player joins
Heres some example code
local groupid = --insert group id here
game.Players.PlayerAdded:Connect(function(player)
local rank = player:GetRankInGroup(groupid)
if rank == 255 then
local tool = tool:Clone
tool.Parent = player.Backpack
end
end)
Okay but how to make them get a tool?
Probably something like this - in ServerScriptService
local groupID = 000 --your group id
local requiredRank = 00 -- the rank needed for the role
local toolLocation = game.Blah.Blah.Blah -- find the tool
game.Players.PlayerAdded:Connect(function(plr)
local role = plr.GetRankInGroup(groupID)
if role >= requiredRank then
local tool = toolLocation:Clone()
local toolCloneAgain = toolLocation:Clone()
tool.Parent = plr.Backpack
toolCloneAgain.Parent = plr.StarterGear
end
end)
@Paul00990 Please also move this topic to #help-and-feedback:scripting-support
Okay I moved it but I dont understand it
local toolLocation = game.Blah.Blah.Blah â find the tool
Just find (locate) the tool, for example,
game.ReplicatedStorage.Tools.Tool
So I just change this
game.ReplicatedStorage.Tools.Hello
Is your tool called âhello
â and is placed inside of ReplicatedStorage
?
If so, then yes.
Put the tools into ServerStorage or ReplicatedStorage. Then, add a script into ServerScriptStorage and paste:
local tools = {
game.ServerStorage.Tool1,
game.ServerStorage.Tool2, --Defines the tools and makes it easier to do stuff. You can add more if you want to but you need a comma after every one up until the second to last one.
game.ServerStorage.Tool3
}
local grp = 00000 --Replace 00000 with your group ID.
---
game.Players.PlayerAdded:Connect(function(plr) --Connects a function when a player joins
if plr:GetRankInGroup(grp) >= 000 then --Checks if they are above minumum rank
plr.CharacterAdded:Connect(function() --Connects a function when the player respawns/spawns
local tool = tools[1]:Clone() --Clones the tool and defines it
tool.Parent = plr.Backpack --Moves the tool into the player's backpack
end)
end
end)
You can copy and paste everything below âââ and change â000â and âtools[1]â (only change the number) to fit your needs.
This script doesnât add the tool to the playerâs StarterGear because the script clones a tool into the backpack everytime the player respawns/spawns.
If your tools are in ReplicatedStorage, then change âServerStorageâ to âReplicatedStorageâ
Just a heads up,
You should replace âGetRoleInGroupâ with âGetRankInGroup.â
plr:GetRoleInGroup() returns a string and you canât compare strings and numbers.
Oh yeah, my bad. I tend to get those 2 mixed up.
@Paul00990 Did you manage to get it working?
It is not working for some reason. The tool is in replicated storage
local groupID = 8347300 --your group id
local requiredRank = 255 â the rank needed for the role
local toolLocation = game.ReplicatedStorage.Tools.Detain â find the tool
game.Players.PlayerAdded:Connect(function(plr)
local role = plr:GetRoleInGroup(groupID)
if role >= requiredRank then
local tool = toolLocation:Clone()
local toolCloneAgain = toolLocation:Clone()
tool.Parent = plr.Backpack
toolCloneAgain.Parent = plr.StarterGear
end
end)
Change plr:GetRoleInGroup
to plr:GetRankInGroup
local groupID = 8347300 --your group id
local requiredRank = 255 --the rank needed for the role
local toolLocation = game.ReplicatedStorage.Tools.Detain --find the tool
game.Players.PlayerAdded:Connect(function(plr)
local role = plr:GetRankInGroup(groupID)
if role >= requiredRank then
local tool = toolLocation:Clone()
local toolCloneAgain = toolLocation:Clone()
tool.Parent = plr.Backpack
toolCloneAgain.Parent = plr.StarterGear
end
end)
It still wont work
Let me do some testing real quick.
It worked perfectly fine for me, can you open the output window and tell me what it says?
17:06:05.305 - Project Science [BETA] auto-recovery file was created
Community Leaderboard script loaded
17:06:06.013 - Tools is not a valid member of ReplicatedStorage âReplicatedStorageâ
17:06:06.014 - Stack Begin
17:06:06.014 - Script âServerScriptService.Scriptâ, Line 3
17:06:06.015 - Stack End
17:06:07.656 - Donation Board: Authorised - Loading Modules
17:06:07.657 - HTTP 403 (Forbidden)
17:06:07.657 - Stack Begin
17:06:07.657 - Script âWorkspace.AdminToolsâ, Line 62
17:06:07.658 - Stack End
17:06:07.658 - :: Adonis :: Loading existing player: Paul00990
17:06:07.658 - 502: API Services rejected request with error. HTTP 403 (Forbidden)
17:06:07.659 - Stack Begin
17:06:07.659 - Script âWorkspace.Boards.SettingsHandlerâ, Line 14
17:06:07.659 - Stack End
17:06:08.210 - Donation Board: ProcessReceipt Activated
17:06:09.935 - :: Adonis :: Loading Complete; Required by 0.31495003846204.Loader.Loader
17:06:11.016 - Infinite yield possible on âReplicatedStorage.ACS_Engine.Eventos.Rappel:WaitForChild(âRopeEventâ)â
17:06:11.016 - Stack Begin
17:06:11.017 - Script âServerScriptService.ACS_Serverâ, Line 1384
17:06:11.017 - Stack End
17:06:13.563 - :: Adonis :: Beginning Adonis cleanup & shutdown processâŚ
17:06:13.565 - -----------------------------------------------
17:06:13.565 - Adonis is already running! AbortingâŚ
17:06:13.565 - Running Location: Workspace.Adonis_Loader.Loader.
17:06:13.566 - This Location: ServerScriptService.Adonis_Loader.Loader.
17:06:13.566 - -----------------------------------------------
17:06:13.567 - :: Adonis :: Unloading complete
17:06:19.157 - Disconnect from ::ffff:127.0.0.1|57660
Can you show me a screenshot of ReplicatedStorage
?