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

I am trying to make a SCPF group, and the scripting doesnt work, how do I fix this?

I am trying to help script to where a specific rank in the SCPF group gets a specific card. However, it's not giving anything to any rank. Can someone help?

game.Players.PlayerAdded:Connect(function(plr)
    local backpack = plr:WaitForChild("Backpack")
    local playerRanking = plr:GetRankInGroup(3739216)

    local toolBasedOnRanking = {
        245 = "[SCP]Card-L0",
        246 = "[SCP]Card-L1",
        247 = "[SCP]Card-L2",
		248 = "[SCP]Card-L3",
		249 = "[SCP]Card-L4",
		250 = "[SCP]Card-L5",
		251 = "[SCP]Card-Omni",
		252 = "[SCP]Card-Omni",
		253 = "[SCP]Card-Omni",
		254 = "[SCP]Card-Omni",
		255 = "[SCP]Card-Omni"
    }

    local tool = game.ServerStorage[toolBasedOnRanking[playerRanking]]
    if tool then
	print("Adding tool!")
        tool:Clone().Parent = backpack
    end
end

1 comment

0

I really need help on this

2 answers

This is happening because you are forgetting the :Clone at the end of line 11.

Here's a tip:

Use variables so you don't have to repeat yourself so much. It also makes code easier to read.

game.Players.PlayerAdded:Connect(function(plr)
	local backpack = plr:WaitForChild("Backpack")
	local playerRanking = plr:GetRankInGroup(3739216)
	-- rest of code
end)

If you'd like to go even further, I'd make a table to represent which items are associated with which rankings:

game.Players.PlayerAdded:Connect(function(plr)
	local backpack = plr:WaitForChild("Backpack")
	local playerRanking = plr:GetRankInGroup(3739216)
	
	local toolBasedOnRanking = {
		rank245 = "[SCP]Card-L0",
		rank246 = "[SCP]Card-L1",
		-- etc.
	}
	
	local rankIndex = "rank" .. tostring(playerRanking)
	local tool = game.ServerStorage[toolBasedOnRanking[rankIndex]]
	if tool then
		tool:Clone().Parent = backpack
	end
end

1 comment

0

It tried to, it didn't end up doing anything

game.Players.PlayerAdded:Connect(function(Player)

local Card0 = game.ServerStorage:WaitForChild("[SCP]Card-L0")
local Card1 = game.ServerStorage:WaitForChild("[SCP]Card-L1")
local Card2 = game.ServerStorage:WaitForChild("[SCP]Card-L2")
local Card3 = game.ServerStorage:WaitForChild("[SCP]Card-L3")
local Card4 = game.ServerStorage:WaitForChild("[SCP]Card-L4")

local Backpack = Player:WaitForChild("Backpack")

if Player:GetRankInGroup(3739216) == 245 then
	Card0:Clone()
	Card0.Parent = Backpack

elseif Player:GetRankInGroup(3739216) == 246 then
	Card1:Clone()
	Card1.Parent = Backpack

elseif Player:GetRankInGroup(3739216) == 247 then
	Card2:Clone()
	Card2.Parent = Backpack

elseif Player:GetRankInGroup(3739216) == 248 then
	Card3:Clone()
	Card3.Parent = Backpack

elseif Player:GetRankInGroup(3739216) == 249 then
	Card4:Clone()
	Card4.Parent = Backpack
end
end)

2 comments

0

Didn't do anything.

0

woopsy daisy, i missed something, i fixed it now tho i think. it should work now.

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