How to make the number randomized?

local Model = script.Parent.Parent
local ProximityPrompt = script.Parent

ProximityPrompt.Triggered:Connect(function(player)
	Model.SurfaceGui.TextLabel.Text = math.random(34,37) .. ".3°C"
	Model.SurfaceGui.TextLabel.Text = math.random(35,36) .. ".5°C"
	Model.SurfaceGui.TextLabel.Visible = true
	Model.Normal.Transparency = 0
	script.BeepSound:Play()
	wait(1)
	Model.SurfaceGui.TextLabel.Visible = false
	Model.Normal.Transparency = 1
	script.BeepSound:Stop()
end)

So basically sometimes the text will be randomized to between 34 or 37 and sometimes randomized to between 35, 36 but I want it seperated.

local Model = script.Parent.Parent
local ProximityPrompt = script.Parent

ProximityPrompt.Triggered:Connect(function(player)
	if math.round(math.random(1, 2)) == 1 then
               Model.SurfaceGui.TextLabel.Text = math.random(34,37) .. ".3°C"
	else
               Model.SurfaceGui.TextLabel.Text = math.random(35,36) .. ".5°C"
        end
	Model.SurfaceGui.TextLabel.Visible = true
	Model.Normal.Transparency = 0
	script.BeepSound:Play()
	wait(1)
	Model.SurfaceGui.TextLabel.Visible = false
	Model.Normal.Transparency = 1
	script.BeepSound:Stop()
end)

Maybe?

Edit: Thanks @typedwaves, forgot

2 Likes

You should use math.round() on the math.random() function as it returns a float not an int.

For example:

print(math.round(math.random(1,2)))
--// 2

print(math.random(1,2))
--// 1.6936598 (just typed this, might not be accurate to actual value)
1 Like