Hello, Im trying to spawn in a certain part at a certain location using the string of a random rarity generator i made. I just cant seem to figure out how to reference the string as a Boolean value.
local Spawner = script.Parent
local ServerStorage = game:GetService("ServerStorage")
local AridPlants = ServerStorage:FindFirstChild("AridPlants")
local Rarity = {
{"Common",40},
{"UnCommon",35},
{"Rare",20},
{"Legendary",4},
{"Mythic",1}
}
local TotalWeight = 0
for _,ItemData in pairs(Rarity) do
TotalWeight = TotalWeight + ItemData[2]
end
local function chooseRandomRarity()
local chance = math.random(1,TotalWeight)
local counter = 0
for _,ItemData in pairs(Rarity) do
counter = counter + ItemData[2]
if chance <= counter then
return ItemData[1]
end
end
end
while true do
Spawner.ClickDetector.MouseClick:Wait()
print(chooseRandomRarity())
end
if chooseRandomRarity() == "Common" then
local c = AridPlants:FindFirstChild("1")
c.Parent = game.Workspace.PlantSpawner
c:MoveTo(Spawner.Position)
print("Spawned")
end

1 comment
You mean return something on a function if its a string? If it is, use if typeof(variable) == "string" then