Simple Loot Dropper only dropping one of two possible loots

Can anyone point me in the direction of why this math.random script will only drop “crystals” and drops nothing if “shards” is selected? Is my syntax in, If then else incorrect?No errors in output.

print ("I died")		
	local crystal= game.ReplicatedStorage.Crystals:WaitForChild("Red")
		local shard= game.ReplicatedStorage.Crystals:WaitForChild("RedShard")
		local dropChance = 25
		local droppedCrystal = nil
		local randomDrop = math.random(1,100)
		if randomDrop > dropChance then droppedCrystal=shard:Clone()
				droppedCrystal = crystal:Clone()

			droppedCrystal.Parent = game.Workspace
			droppedCrystal.Position =,-4,0)

		local collectScript = game.ReplicatedStorage:FindFirstChild("Collect"):Clone()
			collectScript.Parent = droppedCrystal

Side note, why have I been having problems defining a clones position before parenting it to workspace? I thought that was the better order but every time I try to parent after defining position it never seems to position correctly.

Thanks for any feedback!

if randomDrop > dropChance then droppedCrystal=shard:Clone()

how come it doesn’t have its own section of code for:

droppedCrystal.Parent = game.Workspace
droppedCrystal.Position =,-4,0)

Currently you have it in the else part of the code, which means despite the if statement making dropped crystal a shard, it never is parented or positioned, or so I assume such from the code you’ve given.

1 Like

Thank you very much, that was exactly it!

I moved the end to after the else so the parenting and position would apply to either outcomes.

1 Like