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 10 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,

01local List = script.Parent.Parent.List
02local OpenClose = script.Parent
03local bounce = false
04script.Parent.MouseButton1Click:connect(function()
05if bounce == false then
06List:TweenSizeAndPosition(UDim2.new(0,500,0,300),UDim2.new(0,150,0,250),"Out","Back",1)
07OpenClose:TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Back", 1)
08wait(1)
09bounce = true
10elseif bounce == true then
11List:TweenSizeAndPosition(UDim2.new(0,0,0,0),UDim2.new(0,150,0,250),"Out","Back",1)
12OpenClose:TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Back", 1)
13wait(1)
14bounce = false
15end
16end)

1 answer

Log in to vote
1
Answered by
bobder2 135
10 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:

01value = game.ReplicatedStorage.stringValue
02button = script.Parent.Button
03label = script.Parent.Label
04 
05value.Changed:connect(function()
06    label.Text = value.Value
07end)
08 
09button.MouseButton1Click:connect(function()
10    if value.Value == "Hello" then
11        value.Value = "World"
12    else
13        value.Value = "Hello"
14end)
0
So where would I put this in the script above to make it function? Anciteify 70 — 10y
0
Sorry complete noob when comes to scripting... Anciteify 70 — 10y
Ad

Answer this question