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 7 years ago
Edited 7 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

1if random == 1 then
2    local NewLoot = Loot:Clone()
3    NewLoot.CFrame = LootBrick.CFrame
4end
5if random == 2 then
6    local NewLoot = Loot1:Clone()
7    NewLoot.CFrame = LootBrick.CFrame
8 
9end

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 7 years ago

Problem is here

1Loot = 1
2Loot1 = 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

1Loot = 1
2Loot1 = 2
0
Thanks! I didn't realize my mistake.. Sorry my code was pasted all weird TheFierceWaffle 64 — 7y
Ad

Answer this question