Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Math.random and position help?

Asked by 2 years ago

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)

0
If you want a 1% change, you can use math.Random. kingtasaz123 6 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

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)
0
naw jit really forgot to add the certain position part :C greatneil80 2647 — 2y
0
fr kegirosou 17 — 2y
Ad

Answer this question