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

This GUI moving script wont work? Sort-of Solved

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

✓ Accepted answer

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.

5 comments

0

Sorry I kind of accepted your answer before I tried... It still doesnt work.

0

What is the error this time?

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

0

Yeah, that works, but is there a way to make the Passcode frame come faster?

0

Increase the number you're incrementing by e.g. UDim2.new(0, 4, 0, 0)

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).

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