I was wondering if anyone on the forum could help me with that. All I want to do is when I push the button again to go to its original position.
All you need to do is reverse all the tweens that you did when you first click the button.
With what?I tried to make a function on click but it didn’t work and I tried else but the same
Here is the script that CHANGE THE BUTTON POSITION:
local function onClick()
script.Parent.Parent.Frame.Visible = false
script.Parent.Parent.NewsButton.Visible = false
script.Parent.Parent.PlayButton.Visible = false
script.Parent.Parent.QuitButton.Visible = false
script.Parent.Parent.SettingButton.Visible = false
script.Parent.Parent.ExtraInfo.Visible = false
script.Parent.Parent.CreditsButton:TweenPosition(UDim2.new(0.904 , 0 , 0.921 , 0))
end
script.Parent.MouseButton1Click:Connect(onClick)
script.Parent.CreditsButton.MouseButton1Click:Connect(onClick)
Use the starting position of the button, the way it is at the start. Take the Position of that and copy it into this script:
script.Parent.Parent.CreditsButton:TweenPosition(UDim2.new(0, 0, 0, 0)) -- Replace 0, 0, 0, 0 with the original position.
It didn’t work. Nothing happened.
Here So you could have a varible name touched
To Check If the Player Clicked the Button
local touched = false
if touched == false then
//First Click send to desired Position
script.Parent.Parent.CreditsButton:TweenPosition(UDim2.new(0,0,0,0), "InOut", "Sine", 2)
touched = true
else if touched == true then
// Second Click Return to the oritinal Position
script.Parent.Parent.CreditsButton:TweenPosition(UDim2.new(0,0,0,0), "InOut", "Sine", 2)
touched = false
end
end
Tell me if this works ![]()
At first nothing was happening but i managed to make it work.Thanks for the help!
Here it is the script that worked(edit your post to make it the solution)
local touched = false
– When the Player Clicks the frame once you could set it to true.
script.Parent.Parent.CreditsButton.MouseButton1Down:Connect(function()
if touched == false then
--//First Click send to desired Position
script.Parent.Parent.CreditsButton:TweenPosition(UDim2.new(0.774,0,0.997,0), "InOut", "Sine", 2)
touched = true
else if touched == true then
--// Second Click Return to the oritinal Position
script.Parent.Parent.CreditsButton:TweenPosition(UDim2.new(0.279,0,0.142,0), "InOut", "Sine", 2)
touched = false
end
end
end)