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

How Do I Make A Loot System?

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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 
0
Thanks! I didn't realize my mistake.. Sorry my code was pasted all weird TheFierceWaffle 64 — 6y
Ad

Answer this question