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

This GUI moving script wont work? Sort-of Solved

Asked by 9 years ago

Line 12 errors out and says ')' expected near ','

Pass= script.Parent.Parent.Parent.Passcode

function Clicked() 
    for i=1, 10 do
    wait(0.1)
    script.Parent.ImageTransparency = script.Parent.ImageTransparency +0.1
    end 
    wait(0.3)
    script.Parent.Parent.Visible = false
    for b=1,600 do
    wait(0.1)
    Pass.Position.Vector2.new = Pass.Postion + (0,+0.1)(0,0) --errors out
    end
end


script.Parent.MouseButton1Down:connect(Clicked)

2 answers

Log in to vote
2
Answered by
Merely 2122 Moderation Voter Community Moderator
9 years ago

Change this:

Pass.Position.Vector2.new = Pass.Postion + (0,+0.1)(0,0) --errors out

to this:

Pass.Position = Pass.Position + UDim2.new(0, 0.1, 0, 0)

UDim2 is the name for the data type where x and y each have a scale and an offset. In the properties menu you can set them to { 0, 0.1 }, { 0, 0 } but in Lua you need to use the UDim2 constructor.

0
Sorry I kind of accepted your answer before I tried... It still doesnt work. My_Comment 95 — 9y
0
What is the error this time? Merely 2122 — 9y
0
Another thing: you can't have a offset in a UDim2 less than one. Try changing line 12 to use UDim2.new(0, 1, 0, 1) instead of 0.1 Merely 2122 — 9y
0
Yeah, that works, but is there a way to make the Passcode frame come faster? My_Comment 95 — 9y
0
Increase the number you're incrementing by e.g. UDim2.new(0, 4, 0, 0) Merely 2122 — 9y
Ad
Log in to vote
-1
Answered by 9 years ago

These scripts normally work like this:

local gui = game.StarterGui.ScreenGui
local amount = math.random(1,100)
while true do
wait(1)
gui.Frame.TextBox.Position = gui.Frame.TextBox.Position + UDim2.new(0,amount)
wait(5)
gui.Frame.TextBox.Position = gui.Frame.TextBox.Position - UDim2.new(0,amount)

end

This is a complicated example, but it works. First, we get the Gui, then we get the Amount to add (Right now, it's a random number from 1 to 100). We start while true do to loop this script, then add a random number onto the y axis. Then we wait 5 seconds. After five seconds, it subtracts a random number to stop the textBox from getting out of your view (Well, for a while).

Answer this question