Is there possibly somewhere that I missed that specifies the amount of items there are?
You are missing the ,
after every rarity. Make sure you put them after every Value inside the table expect the last.
local Table = {
["Player1"] = "OriChanRBLX",
["Player2"] = "No One", -- Missing
["Player3"] = "lol"
}
Great! That fixed that error, but there’s one more here.
Once again, I’m so sorry for taking up so much of your time.
Oh, there is no Coin with that specific type. For example, if you have different rarities like Gold, Brozen, God,… then you will need to have different coins like GoldCoin, BrozenCoin, GodCoin, … and store it inside the CoinStorage. Make sure it’s a part not model.
Well, these coins are made up a few pieces. All of them except for “Infi” have 2 pieces, the meshpart, and the neon. The “Infi” has a flipped normals for a cel-shading effect, the meshpart, and the neon.
Then you will to change the code that change it position from ClonedCoin.Position = Vector3.new(math.random(1, 100), 1, math.random(1, 100))
to ClonedCoin.PrimaryPart.CFrame = CFrame.new(math.random(1, 100), 1, math.random(1, 100))
… Make sure you welds all the part together and change the model PrimaryPart to the Base part
Ok, so with the Clone error, do I have to add the names of all the coins into the parentheses following “Clone”?
No, you just need to add different coins which name have this following recipe Rarity+Coin
like GoldCoin
, BrozenCoin
, …
Into the CoinStorage
not the :Clone()
xd
Ok, now I’ve done that, but it says:
Workspace.Script:94: attempt to index nil with 'CFrame'
Have you set the Models Achivable to all True?
I forgot to do the primary parts.
Now finally there are no errors, but I don’t see any coins. Is there a timer for when one spawns in the script?
You can put all of them inside the loop with wait(time)
function.
while wait(5) do -- Every 5 seconds
-- Put the spawn scripts here
end
Okay, I want to send this to you to make sure everything is correctly done.
function RandomWithPercentage(LootTable)
if LootTable then
local Total_Percentage = 0
for _, total_percent in pairs(LootTable) do
Total_Percentage += total_percent
end
if Total_Percentage == 100 then
local WeightedLootTable = {}
-- Get Multiplys
local WeightedMultiplys = 1
for _, percentage in pairs(LootTable) do
if percentage < 1 then
local TotalMultiplied = 0
for i = 0, 10 do
if percentage < 1 then
percentage *= 10
TotalMultiplied += 1
end
end
if TotalMultiplied > WeightedMultiplys then
WeightedMultiplys = TotalMultiplied
end
end
end
-- Multiplying WeightedTable
for item, percentage in pairs(LootTable) do
local WeightedPercentage = percentage
for i = 0, WeightedMultiplys do
WeightedPercentage *= 10
end
WeightedLootTable[item] = WeightedPercentage
end
-- Doing a Double Check
local Smallest_Percent = math.huge
for _, percentage in pairs(WeightedLootTable) do
if percentage < Smallest_Percent then
Smallest_Percent = percentage
end
end
if Smallest_Percent > 10 then
for item, percentage in pairs(WeightedLootTable) do
WeightedLootTable[item] = percentage / 10
end
end
-- Randomizing
local sum = 0
for k, v in pairs(WeightedLootTable) do
sum = sum + v
end
local r = math.random(sum)
for k, v in pairs(WeightedLootTable) do
r = r - v
if r <= 0 then
return k
end
end
end
else
warn("Randomizing requires a loot table!")
end
end
local CoinRarity = {
["Bronze"] = 45, -- Have 70% to spawn
["Silver"] = 33, -- Have 33% to spawn
["Gold"] = 13, -- Have 30% to spawn
["Diamond"] = 5, -- Have 5% to spawn
["God"] = 3, -- Have 3% to spawn
["Infi"] = 1 -- Have 1% to spawn
}
local CoinStorage = game.ReplicatedStorage.CoinFolder-- Where you store the coins
local RandomCoinType = RandomWithPercentage(CoinRarity)
local CoinMeshes = CoinStorage:FindFirstChild(RandomCoinType.."Coin") -- If it give Gold rarity, then you should have a Coin meshes named ```GoldCoin```.
local ClonedCoin = CoinMeshes:Clone()
ClonedCoin.PrimaryPart.CFrame = CFrame.new(math.random(1, 100), 1, math.random(1, 100))
end
No errors, and no coins
You haven’t give where will it spawn. Give the ClonedCoin a Parent which is workspace
Is ClonedCoin a part, or a coin model
Its a Model and give it a parent inside Workspace
As so?
Bro, you should learn about how to script.
local CoinMeshes = CoinStorage:FindFirstChild(RandomCoinType.."Coin") -- If it give Gold rarity, then you should have a Coin meshes named ```GoldCoin```.
local ClonedCoin = CoinMeshes:Clone()
ClonedCoin.PrimaryPart.CFrame = CFrame.new(math.random(1, 100), 1, math.random(1, 100))
ClonedCoin.Parent = workspace
Thank you so much. Sorry to be an annoyance, I’m trying to take small steps at a time. I’ll credit you if I ever get my game out