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

Move a frame in the GUI with an ImageButton?

Sorry for bad english. I have a problem.

I have this in my StarterGUI->

ScreenGUI (Name: SHOP) -> Frame -> ImageLabel -> ImageButtons.

In one of my "ImageButtons" i have the " X " for close the Frame. I have insert this LocalScript inside ->

local frame = script.Parent.Parent:WaitForChild('SHOP').Frame
local toggle = false
script.Parent.MouseButton1Click:connect(function()
	if toggle == false then
	frame:TweenPosition(UDim2.new(0.564,-250,0.637,-200),'Out', 'Bounce', 1)
	toggle = true
	else
	frame:TweenPosition(UDim2.new(0.5,-250,1.7,-200),'Out', 'Bounce', 1)
	toggle = false
	
	end
end)

But not work in game, if i press the "X" Nothing work. When people press the "X" i need the Frame go to this coords ->

	frame:TweenPosition(UDim2.new(0.5,-250,1.7,-200),'Out', 'Bounce', 1)

Thanks

2 comments

0

Spiega meglio ( no che spiegi male, ma non capisco anchora il problema )

0

Praticamente , quando si apre lo SHOP, in alto possiede la X per chiuderlo, e non riesco a far funzionare la X che mi chiuda il Frame dello Shop

2 answers

You just didn't add the line (click)

local frame = script.Parent.Parent:WaitForChild('SHOP').Frame
local toggle = false
---------------------------------------------------------
script.Parent.MouseButton1Click:Connect(function(click)
		if toggle == false then
frame:TweenPosition(UDim2.new(0.564,-250,0.637,-200),'Out', 'Bounce', 1)
		toggle = true
	else 
frame:TweenPosition(UDim2.new(0.5,-250,1.7,-200),'Out', 'Bounce', 1)
		toggle = false
	end
end)

You could also do this...

local frame = script.Parent:WaitForChild('Frame')
local toggle = false
---------------------------------------------------------
script.Parent.MouseButton1Click:Connect(function(click)
		if toggle == false then
frame:TweenPosition(UDim2.new(0.564,-250,0.637,-200),'Out', 'Bounce', 1)
		toggle = true
	else 
frame:TweenPosition(UDim2.new(0.5,-250,1.7,-200),'Out', 'Bounce', 1)
		toggle = false
	end
end)

See if these two work.

4 comments

0

Not work...

0

So is this a GUI button that does both or do you have a X button that closes it and a button that opens it, also it has to be in a frame, at least of what I know.

0

The X only close the Frame, but the frame is opened by an another button in StarterGUI

0

Then you can't do it, it has to be inside a GUI Frame, apologies

Italiano/Italian Quando premi la X per chiudere il menu, non vuoi più aprirlo. Quindi la X ha una sola funzione o attività.

Non ha bisogno di altro perché il suo ruolo è quello di "spegnere" o modificare la cornice, non per mantenerlo nella sua posizione originale, quindi:

UDim2.new(0.564,-250,0.637,-200)

Codice Finale:

local frame = script.Parent.Parent:WaitForChild('SHOP').Frame

script.Parent.MouseButton1Click:connect(function()
    frame:TweenPosition(UDim2.new(0.5,-250,1.7,-200),'Out', 'Bounce', 1)
end)

spero che hai capito e che ti ho aiutato.

Inglese/English When you press the X to close the menu, you don't want to open it again. So the X has only one function or activity.

He doesn't need anything else because his role is to "turn off" or change the frame, not to keep it in its original position, so:

UDim2.new(0.564,-250,0.637,-200)

Final Script:

local frame = script.Parent.Parent:WaitForChild('SHOP').Frame

script.Parent.MouseButton1Click:connect(function()
    frame:TweenPosition(UDim2.new(0.5,-250,1.7,-200),'Out', 'Bounce', 1)
end)

I hope you understand and that I helped you.

1 comment

0

Non funziona / Not work...

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