I have an error

The error is Workspace.Model.Temperature Scanner.Part.ProximityPrompt.Script:5: wrong number of arguments

This is my script.

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

ProximityPrompt.Triggered:Connect(function(player)
	if math.round(math.random(1, 2, 3)) == 1 then
		Model.SurfaceGui.TextLabel.Text = math.random(34,37) .. ".3°C"
	elseif math.round(math.random(1, 2, 3)) == 2 then
		Model.SurfaceGui.TextLabel.Text = math.random(35,36) .. ".5°C"
	else
		Model.SurfaceGui.TextLabel.Text = math.random(34,36) .. ".4°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)

math.random() only requires two arguments, the min and the mix.

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

ProximityPrompt.Triggered:Connect(function(player)
	if math.round(math.random(1, 3)) == 1 then
		Model.SurfaceGui.TextLabel.Text = math.random(34,37) .. ".3°C"
	elseif math.round(math.random(1, 3)) == 2 then
		Model.SurfaceGui.TextLabel.Text = math.random(35,36) .. ".5°C"
	else
		Model.SurfaceGui.TextLabel.Text = math.random(34,36) .. ".4°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)
1 Like

If the first argument to math.random() is 1 then it can be omitted as that is its default.

math.random(3) will suffice.

1 Like