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

GUI positioning help?[Solved]

Asked by 9 years ago

I just want to know what to do to make this actually move, I've pointed out where my confusion is.

while true do
    wait(1)
    Value = math.random(100,500)
    if script.Parent.Parent.Tool.Enabled == true then
    script.Parent.Position = (Value,Value) --Not sure how to format this
    end
end

Edit

while true do
    wait(1)
    Value = math.random(100,500)
    if script.Parent.Parent.Tool.Enabled == true then
    script.Parent.Position = UDim2.new(0,Value,0,Value)
    end
end

ANY Help is appreciated! Thanks!

0
I haven't done what you're doing currently. Although, try this for line 5: script.Parent.Postiion = UDim2.new(Value,Value) alphawolvess 1784 — 9y
0
What are you trying to do? Continuously have this shift around your screen? alphawolvess 1784 — 9y
0
Not necessarily, but knowing how to get it to do that will make it easy to do what I want. BSIncorporated 640 — 9y
0
Nvm, im just an idiot lol, my hierarchy wasn't correct BSIncorporated 640 — 9y

2 answers

Log in to vote
4
Answered by 9 years ago

UDim2's are the way GUI's position themself on-screen. They take scales and offsets. Scales are values from 0 to 1 while offsets can be anything as it gets the actual pixel distance. Don't do what chill did and make the scale over 1, otherwise the GUI won't even be on the screen.

while wait(1)
    Value = math.random(100,500)
    if script.Parent.Parent.Tool.Enabled == true then
    script.Parent.Position = UDim2.new(0,Value,0,Value)
    end
end

Ad
Log in to vote
1
Answered by 9 years ago

You should use the UDim2 keyword, Just Like CFrame is used for moving Parts UDim2 is used for moving GUI's

script.Parent.Position =UDim2.new (Value, Value, Value, Value) -- Since there are 4 values in The Gui you have to input 4 values
0
Thank you! BSIncorporated 640 — 9y
0
You are welcome chill22518 145 — 9y
0
It's still not quite working. BSIncorporated 640 — 9y
0
because the Value is only one number not 2. chill22518 145 — 9y

Answer this question