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

How Can I fix My RNG Dropping system?

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

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

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