Im new to scripting but I would like to know how you can position a ScreenGui with a script. It would be awesome if you could even tell me how I could randomly position it in a loop.
How do I position a Gui with a script? I can't figure it out on my own.
2 answers
put this code in a regular script. Put the script a parent of the frame (Put the script inside the frame). Then we will use the math math.random() to pick a random number for us.
so like:
local frame = script.Parent.Parent.Frame
while wait(.1) do -- change the wait delay higher to make it go slower!
frame.Position = UDim2.new(math.random(),math.random(), math.random())
end
if you want it to go random position but in certain areas you can just add values in the math.random()
for example:
math.Random(100)
The (100) picks any random number below 100.
If this works please accept this answer! Thank you!
-Mohawkid14
2 comments
when i enter a value noting will show up, so when i don't put anything in it will show it moving randomly but in the corner only.
I know this post is already old, but I highly recommend you use localscripts instead of regular (server) scripts. If you're using FilteringEnabled, the GUI will NOT work with server scripts! Even if you don't use it, I still recommend using localscripts.
You use something called UDim2 to set the position of a GUI. Also you can't set a ScreenGui position, that's just something that holds the GUI. :P
If you want it to be in a loop and do random positions, you can use a while true do loop and math.random to do it.
It'd be something like this :
while wait(.1) do
script.Parent.Position = UDim2.new(math.random(),math.random(),math.random(),math.random())
end
Hope this helped! :D
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
http://wiki.roblox.com/index.php?title=UDim2