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

getting random child from model gives error?

Asked by
danglt 185
4 years ago

When I try to get a random tool aka child i get an error Players.Danglt.Backpack.Remote.Tool:14: attempt to index field 'random' (a function value)

local crate2 = storage.Crate:Clone()
    for i,v in pairs(storage.rewards:GetChildren()) do
        local reword = v[math.random[1]]:Clone()
        reword.Parent = crate2.Reward
    crate2.Parent = workspace
    crate2.Configurations.Owner.Value = plr.Name
    for i = 1,1 do -- Replace 100 with an increment of times
crate2.Base:SetPrimaryPartCFrame(char.Torso.CFrame + Vector3.new(10,10,0))
end
0
I am bad at this, but maybe try a # before the 1 in line 3...?? PaliKai13 92 — 4y
0
nope, now i get Players.Danglt.Backpack.Remote.Tool:14: attempt to get length of a number value danglt 185 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

[] is for index,

() is for function,

so it should be, math.random(1)

Ad

Answer this question