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

Why is my table script still not working?

Still no error on output. Also I have another question is possible so I can make the script not pick one it already did?

`players = game:GetService("Players"):GetPlayers()


Guns = {"AN-94", "DSR50"}

i = math.random(1, #Guns)
F = Guns[i]

if F.Value == "1" then
    x = game.ServerStorage:FindFirstChild("AN-94"):Clone()
    x.Parent = players.Backpack

elseif F.Value == "2" then
	 x = game.ServerStorage:FindFirstChild("DSR50"):Clone()
    x.Parent = players.Backpack
end
`

Basically it's not giving the player any tools. I have no clue why.

2 comments

0

I already answered your question, if there was a problem, why didn't you tell me? Also, please explain your problem next, rather than just posting a script without codeblock.

0

I hardly know how to use this website

1 answer

local players = game:GetService("Players")

for i,v in pairs(players:GetChildren())do 
	local GunNames = {"AN-94", "DSR50"}  
	local Index = math.random(1, #GunNames) 
	local GunName = GunNames[Index] 
	if Index == 1 then  
	    local Gun = game.ServerStorage:FindFirstChild(GunName):Clone() 
	    Gun.Parent = v.Backpack 
	elseif Index == 2 then 
	     local Gun = game.ServerStorage:FindFirstChild(GunName):Clone() 
	    Gun.Parent = v.Backpack 
	end 
end

This should fix your problem.

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