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

Math.random and position help?

So im trying to make a script that when I click a textbutton it spawns a part but add a 1% chance to spawn a red part.I also need help trying to find out how to spawn that part at a certain position.This is my current script:

myPart = Instance.new("Part",game.Workspace) script.parent.MouseButton1Click:Connect(function() Instance.new("Part",game.Workspace) end)

1 comment

0

If you want a 1% change, you can use math.Random.

1 answer

Not sure if this works, didn't test. Let me know.

myPart = Instance.new("Part",game.Workspace) script.parent.MouseButton1Click:Connect(function() 
local rand = math.random(1,100)
if rand == 1 then
	Instance.new("Part",game.Workspace) 
else
	-- didn't get it
	end
end)

2 comments

0

naw jit really forgot to add the certain position part :C

0

fr

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