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

How Can I fix My RNG Dropping system?

Asked by
WishXVI 94
3 years ago

This is my code, line 13, or " local ChosenNumber = math.Random(0,10)" errors, attempted to call nil value. I'm not sure how to fix this because I have never used math.random, have a misplaced a character? (and yes this is in a respawning script)

Dummy = script.Parent.Parent.Dummy
Clone = Dummy:Clone()

function Regen()
wait(3)
Dummy.Parent = nil
Clone.Parent = script.Parent.Parent
Dummy = Clone
Dummy:makeJoints()
Dummy.Torso.CFrame = script.Parent.CFrame + Vector3.new(0,2.7,0)
    Clone = Dummy:Clone()

    local ChosenNumber = math.Random(0,10)

    if ChosenNumber == 10 then

        local clonedsword = game.ReplicatedStorage.Library["Steel Greatsword"]:Clone()
        clonedsword.Parent = game.Players.LocalPlayer.Backpack
    end

    Dummy.Humanoid.Died:connect(Regen)
end

Dummy.Humanoid.Died:connect(Regen)

1 answer

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

It might be because random is capitalized, try doing this (its more condensed as well)

if math.random(0, 10) == 10 then
-- Your code here
end
Ad

Answer this question