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

How do I tween a GUI with a click detector?

Asked by
OOFyie 4
4 years ago
Edited 4 years ago

I should state that I'm not experienced with coding. Like the title says, I can't seem to get the following local script to work correctly.

local gui = script.Gui
local brickClickedEvent = game.ReplicatedStorage.Events.BrickClicked
local frame = script.Parent.Parent.Parent:WaitForChild('Gui').Frame
local toggle = true
local text = script.Parent.Parent.Parent:WaitForChild('Gui').TextButton

 brickClickedEvent.OnClientEvent:Connect(function()
  if toggle == false then
   frame:TweenPosition(UDim2.new(0.25, 0,0.2, 0))
   text:TweenPosition(UDim2.new(0.771, 0,0.183, 0))
   toggle = true
  else
   frame:TweenPosition(UDim2.new(0.25,0,1.5,0))
   text:TweenPosition(UDim2.new(0.771, 0,0.183, 0))
   toggle = false
  end
 end

I'm fairly certain everything else works perfectly fine considering the previous local script used to be,

local gui = script.Gui
local brickClickedEvent = game.ReplicatedStorage.Events.BrickClicked
brickClickedEvent.OnClientEvent:Connect(function()
gui.Enabled = true
end)

and this script worked perfectly, though the problem with this is the TextButton I had used to close out of the gui used a tweening script which means you couldn't reopen the gui with the brick.

Apologies for the screwed up lines, I'm not sure how to properly format the code.

Here is an imgur link to the explorer tab if it's needed.

0
Firstly, you format code by highlighting it and pressing the blue lua button, and secondly, any errors? MachoPiggies 526 — 4y
0
I just checked an apparently I forgot to close the function with a parenthesis. I fixed that error and when I play it again the gui still isn't popping up and nothing is showing up in the output bar. OOFyie 4 — 4y

Answer this question