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

Roblox table script not working?

Asked by 9 years ago

No error I just started using tables BTW

Guns = {"AN-94", "DSR50", "Executioner", "FiveSeven", "KAP40", "MTAR", "RM870", "RocektLauncher", "SkorpoinEVO"}
i = math.random(1, #Guns)
F = Guns[i]

if F.Value == "AN-94" then x = game.ServerStorage:FindFirstChild("AN-94") x:clone() x.Parent = game.workspace

end

0
Try "if F.Value == 1 then" AmiracIe 175 — 9y

1 answer

Log in to vote
0
Answered by
Relatch 550 Moderation Voter
9 years ago

Problems

You need to check if it's equal to 1, not check it's name. Say you are using this table;

MyTable = {"Chicken", 10, true}

1 would be Chicken, 2 would be 10, and 3 would be true.


Fixes

Use if F == "1", rather than what you had before.

You can use x = game.ServerStorage:FindFirstChild("AN-94"):Clone(), rather than adding a new line to clone it.

You can also use x.Parent = workspace, rather than using game.Workspace.


Script

Guns = {"AN-94", "DSR50", "Executioner", "FiveSeven", "KAP40", "MTAR", "RM870", "RocektLauncher", "SkorpoinEVO"}

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

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

Answer this question