вот можно так сделать
local playersSvc = game:GetService('Players')
local RND = Random.new()
local MONSTER_PROPS = {
{['prob'] = 110, ['model'] = workspace["Monster 1"]},
{['prob'] = 350, ['model'] = workspace["Monster 2"]},
{['prob'] = 10, ['model'] = workspace["Rare Monster"]}
}
local PROB_TOTAL = 0
for k, v in pairs(MONSTER_PROPS) do
PROB_TOTAL = PROB_TOTAL + v['prob']
end
for k, v in pairs(MONSTER_PROPS) do
v['prob_ratio'] = v['prob'] / PROB_TOTAL
end
table.sort(MONSTER_PROPS, function(a, b)
return(a['prob_ratio'] > b['prob_ratio'])
end)
local COLOR_IDLE = BrickColor.new('Sand green').Color
local COLOR_ANGRY = BrickColor.new('Really red').Color
local function paint_red(model, flag:boolean)
for k, v in pairs(model:GetDescendants()) do
if v:IsA('Part') or v:IsA('MeshPart') then
if flag then
v.Color = COLOR_ANGRY
else
v.Color = COLOR_IDLE
end
end
end
end
local trigger = workspace.trigger
local MONSTER_BUSY = false
local HANDLER = function(hit)
local success, error = pcall(function()
hit.Parent.HumanoidRootPart:IsA('Part')
for k, v in pairs(playersSvc:GetPlayers()) do
if v.Character == hit.Parent then
break
end
end
end)
if success and not MONSTER_BUSY then
trigger.Color = COLOR_ANGRY
local spawn_prob = RND:NextNumber()
local spawn_model = nil
for k, v in pairs(MONSTER_PROPS) do
if spawn_prob <= v['prob_ratio'] then
spawn_model = v['model']
end
end
if spawn_model then
MONSTER_BUSY = true
paint_red(spawn_model, true)
local hum = spawn_model.Humanoid
hum:MoveTo(hit:GetPivot().Position)
hum.MoveToFinished:Connect(function()
MONSTER_BUSY = false
trigger.Color = BrickColor.new('Lime green').Color
paint_red(spawn_model, false)
end)
end
end
end
HANDLER_HOOK = trigger.Touched:Connect(HANDLER)
local Monster1 = 110
local Monster2 = 350
local RareMonster = 10
Без всяких границ от нуля до единицы и т.д. либо напишите как сделать что-то похожее, нечто большее чем обычный math.random(x,y). В ответе напишите что где к чему.