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

How Do I Make A Loot System?

Alright, I made two parts and named them Loot, and Loot1. Then, I put them into the Replicated Storage. I made a part in workspace named LootBox. In the ServerScriptService, I put a Script saying:

local ReplicatedStorage = game.ReplicatedStorage local Loot = ReplicatedStorage:WaitForChild("Loot") local Loot1 = ReplicatedStorage:WaitForChild("Loot1") local LootBrick = workspace:WaitForChild("LootBox")

Loot = 1 Loot1 = 2

random = (math.random(1,2))

while wait(1)do

if random == 1 then
	local NewLoot = Loot:Clone()
	NewLoot.CFrame = LootBrick.CFrame
end
if random == 2 then
	local NewLoot = Loot1:Clone()
	NewLoot.CFrame = LootBrick.CFrame
	
end

end

I need to know how to fix it, it says "15:48:57.473 - ServerScriptService.Script:18: attempt to index local 'Loot1' (a number value)" Thanks!

1 answer

✓ Accepted answer

Problem is here

Loot = 1 
Loot1 = 2

youre setting loot1 and loot2 to number values and then trying to clone them here but i see previously that you defined them as parts so just remove the following from your code

Loot = 1 
Loot1 = 2 

1 comment

0

Thanks! I didn't realize my mistake.. Sorry my code was pasted all weird

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