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

How do I fix this? And also is it possible to make that team only?

Asked by 4 years ago

Here is my script which is not working right now.

And is it possible to make that team only? Like if the player is on the earth green team it does not spawn but when he is on the light blue team it will. Sorry, I'm not the best when it comes to scripting.

game.Players.PlayerAdded:Connect(function(plr)
if plr:GetRankInGroup(5090028) == 2 then
   local tool = game.ServerStorage["X-26"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 3 then
    local tool = game.ServerStorage["X-26"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 4 then
    local tool = game.ServerStorage["X-26"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 5 then
    local tool = game.ServerStorage["X-26"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 6 then
    local tool = game.ServerStorage["X-26"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 7 then
    local tool = game.ServerStorage["X-26"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 8 then
    local tool = game.ServerStorage["X-26"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
--Flashlight
elseif plr:GetRankInGroup(5090028) == 1 then
    local tool = game.ServerStorage["Flashlight"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 2 then
    local tool = game.ServerStorage["Flashlight"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 3 then
    local tool = game.ServerStorage["Flashlight"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 4 then
    local tool = game.ServerStorage["Flashlight"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 5 then
    local tool = game.ServerStorage["Flashlight"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 6 then
    local tool = game.ServerStorage["X-26"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 7 then
    local tool = game.ServerStorage["Flashlight"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 8 then
    local tool = game.ServerStorage["Flashlight"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
--Police Baton
elseif plr:GetRankInGroup(5090028) == 2 then
    local tool = game.ServerStorage["PoliceBaton"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 3 then
    local tool = game.ServerStorage["PoliceBaton"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 4 then
    local tool = game.ServerStorage["PoliceBaton"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 5 then
    local tool = game.ServerStorage["PoliceBaton"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 6 then
    local tool = game.ServerStorage["PoliceBaton"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 7 then
    local tool = game.ServerStorage["PoliceBaton"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 8 then
    local tool = game.ServerStorage["PoliceBaton"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
--Pepper Spray
elseif plr:GetRankInGroup(5090028) == 2 then
    local tool = game.ServerStorage["PepperSpray"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 3 then
    local tool = game.ServerStorage["PepperSpray"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 4 then
    local tool = game.ServerStorage["PepperSpray"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 5 then
    local tool = game.ServerStorage["PepperSpray"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 6 then
    local tool = game.ServerStorage["PepperSpray"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 7 then
    local tool = game.ServerStorage["PepperSpray"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 8 then
    local tool = game.ServerStorage["Glcok 18"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
--Glock
elseif plr:GetRankInGroup(5090028) == 3 then
    local tool = game.ServerStorage["Glock 18"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 4 then
    local tool = game.ServerStorage["Glock 18"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 5 then
    local tool = game.ServerStorage["Glock 18"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 6 then
    local tool = game.ServerStorage["Glock 18"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 7 then
    local tool = game.ServerStorage["Glock 18"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 8 then
    local tool = game.ServerStorage["Glock 18"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
--ACR 
elseif plr:GetRankInGroup(5090028) == 3 then
    local tool = game.ServerStorage["ACR"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 4 then
    local tool = game.ServerStorage["ACR"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 5 then
    local tool = game.ServerStorage["ACR"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 6 then
    local tool = game.ServerStorage["ACR"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 7 then
    local tool = game.ServerStorage["ACR"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 8 then
    local tool = game.ServerStorage["ACR"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")


end
end)

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

If you're looking for multiple items, you will not get them because once it finds an "if" that is correct, it will run the script and go past all the other elseif's. Here's what I mean as I'm not good explaining errors.

game.Players.PlayerAdded:Connect(function(plr)
if plr:GetRankInGroup(5090028) == 2 then
   local tool = game.ServerStorage["X-26"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 3 then
    local tool = game.ServerStorage["X-26"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 4 then
    local tool = game.ServerStorage["X-26"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 5 then
    local tool = game.ServerStorage["X-26"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 6 then
    local tool = game.ServerStorage["X-26"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 7 then
    local tool = game.ServerStorage["X-26"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 8 then
    local tool = game.ServerStorage["X-26"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
end
--Flashlight
if plr:GetRankInGroup(5090028) == 1 then
    local tool = game.ServerStorage["Flashlight"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 2 then
    local tool = game.ServerStorage["Flashlight"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 3 then
    local tool = game.ServerStorage["Flashlight"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 4 then
    local tool = game.ServerStorage["Flashlight"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 5 then
    local tool = game.ServerStorage["Flashlight"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 6 then
    local tool = game.ServerStorage["X-26"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 7 then
    local tool = game.ServerStorage["Flashlight"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 8 then
    local tool = game.ServerStorage["Flashlight"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
end
--Police Baton
if plr:GetRankInGroup(5090028) == 2 then
    local tool = game.ServerStorage["PoliceBaton"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 3 then
    local tool = game.ServerStorage["PoliceBaton"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 4 then
    local tool = game.ServerStorage["PoliceBaton"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 5 then
    local tool = game.ServerStorage["PoliceBaton"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 6 then
    local tool = game.ServerStorage["PoliceBaton"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 7 then
    local tool = game.ServerStorage["PoliceBaton"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 8 then
    local tool = game.ServerStorage["PoliceBaton"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
end
--Pepper Spray
if plr:GetRankInGroup(5090028) == 2 then
    local tool = game.ServerStorage["PepperSpray"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 3 then
    local tool = game.ServerStorage["PepperSpray"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 4 then
    local tool = game.ServerStorage["PepperSpray"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 5 then
    local tool = game.ServerStorage["PepperSpray"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 6 then
    local tool = game.ServerStorage["PepperSpray"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 7 then
    local tool = game.ServerStorage["PepperSpray"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 8 then
    local tool = game.ServerStorage["Glcok 18"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
end
--Glock
if plr:GetRankInGroup(5090028) == 3 then
    local tool = game.ServerStorage["Glock 18"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 4 then
    local tool = game.ServerStorage["Glock 18"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 5 then
    local tool = game.ServerStorage["Glock 18"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 6 then
    local tool = game.ServerStorage["Glock 18"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 7 then
    local tool = game.ServerStorage["Glock 18"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 8 then
    local tool = game.ServerStorage["Glock 18"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
end
--ACR 
if plr:GetRankInGroup(5090028) == 3 then
    local tool = game.ServerStorage["ACR"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 4 then
    local tool = game.ServerStorage["ACR"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 5 then
    local tool = game.ServerStorage["ACR"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 6 then
    local tool = game.ServerStorage["ACR"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 7 then
    local tool = game.ServerStorage["ACR"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")
elseif plr:GetRankInGroup(5090028) == 8 then
    local tool = game.ServerStorage["ACR"]:Clone()
   tool.Parent = plr:WaitForChild("Backpack")


end
end)

Please comment on this question if I got anything wrong.

0
Oh btw, in this group make sure the rank numbers match the group ranks Jack_Hase 85 — 4y
0
Groiup->Roles->Rank. That's what you're trying to compare it to Jack_Hase 85 — 4y
Ad

Answer this question