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

Ok so I trying to get into GUI's but...?

Asked by 9 years ago

For some reason Surface GUI is not working I have a Imagebutton for a frame to open and close but when I try and click the button it's not highlighting with the black mouse arrow so I don't know what is wrong here's the script I'm using,

local List = script.Parent.Parent.List
local OpenClose = script.Parent
local bounce = false
script.Parent.MouseButton1Click:connect(function()
if bounce == false then
List:TweenSizeAndPosition(UDim2.new(0,500,0,300),UDim2.new(0,150,0,250),"Out","Back",1)
OpenClose:TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Back", 1)
wait(1)
bounce = true
elseif bounce == true then
List:TweenSizeAndPosition(UDim2.new(0,0,0,0),UDim2.new(0,150,0,250),"Out","Back",1)
OpenClose:TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Back", 1)
wait(1)
bounce = false
end
end)

1 answer

Log in to vote
1
Answered by
bobder2 135
9 years ago

SurfaceGuis that are parented to bricks don't support buttons the way you're trying to get them to. In order to make the button work you need to put your SurfaceGui in StarterGui, then make a script to set the SurfaceGui's Adornee property to the brick you want it to be on. If the button is updating anything in your Gui you may want to use an intValue, or a stringValue like so to update it on everyone's screen:

value = game.ReplicatedStorage.stringValue
button = script.Parent.Button
label = script.Parent.Label

value.Changed:connect(function()
    label.Text = value.Value
end)

button.MouseButton1Click:connect(function()
    if value.Value == "Hello" then
        value.Value = "World"
    else
        value.Value = "Hello"
end)
0
So where would I put this in the script above to make it function? Anciteify 70 — 9y
0
Sorry complete noob when comes to scripting... Anciteify 70 — 9y
Ad

Answer this question