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

Players.Marxcalbre.Backpack.LocalScript:8: invalid argument #2 to 'random' (interval is empty)?

--help
--pls
--ineedhelp
game.Workspace.Teletosans.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local hall = game.ReplicatedStorage.HallOfJudgement:Clone()
		hall.Parent = game.Workspace
		hall.Position= Vector3.new(math.random(0,250000000000), math.random(0,250000000000), math.random(0,250000000000))
		local halll = game.ReplicatedStorage.Sans:Clone()
		halll.Parent = game.Workspace
		halll.Position = hall.Vector3*Vector3.new(-9,-9,-9)
		local Teletosans2 = Instance.new("Part")
		Teletosans2.Name = "Teletosans2"
		Teletosans2.Parent = game.Workspace
		Teletosans2.Anchored = true
		Teletosans2.CanCollide = false
		Teletosans2.Transparency = 1
		Teletosans2.Position = halll.Vector3*Vector3.new(-9,0,0)
		
		hit.Parent.HumanoidRootPart.CFrame = game.Workspace.Teletosans2.CFrame
	end
	
end)

1 answer

✓ Accepted answer

You are getting that error due to the fact that math.random’s second argument form has always converted the arguments to signed 32-bit ints so it will have problems with numbers greater than (2^31)-1.

Instead of using math.random(0,250000000000) you can use Random.new():NextInteger(0,250000000000)

Read more about Random here: https://developer.roblox.com/en-us/api-reference/datatype/Random

2 comments

0

THANKS SO MUCH and i just realised that hall is a model so does not have Vector3

0

You can set PrimaryPart of model and use SetPrimaryPartCFrame function to move it (https://developer.roblox.com/en-us/api-reference/function/Model/SetPrimaryPartCFrame)

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