As the title says, I’m making a weapon based off a certain battler in The Battle Bricks, that being Gamble Battler. In the game, he has a 1/6 chance of either firing a powerful shot or failing but each time he fails to fire, he increases the chances of successfully firing and each time he fires, the chances reset.
Now, I know how to make the RNG part with math.random(), although, I don’t know how to make it so that each time you fail, the chances increases. How can I do that exactly?
it’s easy,
local Chance = {Minimum,Max}
–example 1 in 20
local number = math.random(Chance[1],Chance[2]
if number ~= 1 and Chance[2] >= 2 then
print(“unsuccess”)
Chance[2] -= 1
elseif number == 1 and Chance[2] >= 2 then
print(“success”)
end
local Chance = {1,6}
local Number = math.random(Chance[1],Chance[2])
if Number ~= 1 and Chance[2] >= 2 then
GunHandle.Fail:Play()
Chance[2] -= 1
print("CHANCE IS NOW "..Chance[2])
GunHandle.Attachment.ParticleEmitter.Enabled = true
task.wait(0.2)
GunHandle.Attachment.ParticleEmitter.Enabled = false
elseif Number == 1 and Chance[2] >= 2 then
GunHandle.Fire:Play()
GunHandle.Attachment.ParticleEmitter.Enabled = true
ShakeEvent:FireClient(Plr,0.5)
local raycast = workspace:Raycast(GunHandle.Position, (MousePOS - GunHandle.Position).Unit * 200)
local hitbox = raycast.Instance
if hitbox then
local char = hitbox.Parent
local Humanoid = char:FindFirstChild("Humanoid")
if Humanoid and char ~= Plr.Character and Humanoid.Health >= 1 then
Humanoid:TakeDamage(384)
if Humanoid.Health <= 1 then
local BodyVelocity = Instance.new("BodyVelocity",char.PrimaryPart)
BodyVelocity.MaxForce = Vector3.new(1, 1, 1) * math.huge
local Dir = (char.PrimaryPart.CFrame.Position - Plr.Character.PrimaryPart.CFrame.Position).Unit
BodyVelocity.Velocity = (Dir + Vector3.new(0, 3, 0)).Unit * 250
game:GetService("Debris"):AddItem(BodyVelocity,.025)
end
end
task.wait(0.2)
GunHandle.Attachment.ParticleEmitter.Enabled = false
Chance[2] = 6
print("CHANCE RESET BACK TO "..Chance[2])
end