Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

math.random Randomly stopped working. Why?

This is not even a question, So please fix this.

I dont know what happened, But Random.Math stopped working.

( Workspace.Moons.Power Moon.Handler:20: bad argument #2 (interval is empty))

DB = false
MOONPART = script.Parent["Power Moon"].Base
MOONPART.Music:Play()
local Workspace = game:GetService("Workspace")
MOONPART.CFrame = CFrame.new(math.random(-1024,1024),100,math.random(-1024,1024))
MOONPART.Touched:Connect(function(PRT)
	if not DB then
		local HUM = PRT.Parent:FindFirstChild("Humanoid")
		local PLR = game.Players:GetPlayerFromCharacter(PRT.Parent)
		if HUM and PLR then
			local LDR = PLR:FindFirstChild("leaderstats")
			local Points = LDR:WaitForChild("Points")
			local Multi = LDR:WaitForChild("Multiplier")
			local UMulti = LDR:WaitForChild("UL. Multiplier")
			if not HUM or not Points or not Multi or not UMulti then return end
			MOONPART.CoinSound:Play()
			MOONPART.Music:Pause()
			DB = true
			Multi.Value = UMulti.Value+1*Multi.Value + 0.01
			Points.Value = Points.Value + math.random(50,Multi.Value+1*300)
			MOONPART.CoinSound.Ended:Wait()
			MOONPART.Parent.Parent = game.ServerStorage
			wait(10)
			MOONPART.Parent.Parent = script.Parent
    		MOONPART.CFrame = CFrame.new(math.random(-1024,1024),100,math.random(-1024,1024))
			DB = false
		end
	end
end)

function IsInVoid()
	if MOONPART.Position.Y >= -10 then return end
    MOONPART.CFrame = CFrame.new(math.random(-1024,1024),100,math.random(-1024,1024))
end

while wait(1) do
	IsInVoid()
end

For god sake, Lua, What is wrong with you?

3 comments

0

What does Multi.Value+1*300 evaluate to?

0

Please stop asking these question on every single post. I dont know what MULTI evaluates to.

0

How have I asked this question on every post? I am asking you this because it say arguments #2 is a bad argument. Maybe Multi.Value+1*300 evaluates you something you don’t expect. You could check by printing. Just trying to help man

1 answer

You have the values set wrong. Try math.random(1024,-1024)

2 comments

0

Wow, Thats so dumb. It should always be (Lower number) and (higher number) not the oppisiste. I searched for this, And it seems like a intiger overflow, But i dont know how to work around this.

0

That is weird. I thought it did take in the params as (min, max). Did this fix your problem?

This discussion is preserved as it was. New answers, comments, and votes are closed.