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

Why isn't this function firing when this gui button is clicked?

I honestly have no idea whats going on. If anyone could help me figure out why it's not working that'd help.

move = 13
brick = script.Parent
open = false
db = false

game.StarterGui.ScreenGui.Frame.Curtains.MouseButton1Click:Connect(function()
	if db == false then
		db = true
		if open == false then
			open = nil
			for i = 0,move,0.100 do
				brick.CFrame = brick.CFrame*CFrame.new(0,(0.10*1),0)
				wait()
			end
			open = true
		elseif open == true then
			open = nil
			for i = 0,move,0.100 do
				brick.CFrame = brick.CFrame*CFrame.new(0,(0.10*-1),0)
				wait()
			end
			open = false
		end
		db = false
	end
end)

So I have that script in each of my unions. But for some reason it just doesn't work. If it helps the frame is a scrolling frame I just renamed it to work with another script which is the thing you touch to get the Gui.

1 comment

0

not confident in the solution i posted given your message but please update your message above with the "script that you touch to get the Gui"

1 answer

✓ Accepted answer

You need to put the script inside a LocalScript inside your ScreenGui. When your "other script which is the thing you touch to get the Gui" runs the GUI should be moved from your storage point to PlayerGui. Because of this, the script above probably can't find the Curtains

Say you move the following script into a LocalScript object and put it inside Curtains:

local move = 13
local brick = game.Workspace --finish this line to find your brick
local open = false
local db = false
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
    if db == false then
        db = true
        if open == false then
            open = nil
            for i = 0,move,0.100 do
                brick.CFrame = brick.CFrame*CFrame.new(0,(0.10*1),0)
                wait()
            end
            open = true
        elseif open == true then
            open = nil
            for i = 0,move,0.100 do
                brick.CFrame = brick.CFrame*CFrame.new(0,(0.10*-1),0)
                wait()
            end
            open = false
        end
        db = false
    end
end)

1 comment

0

It works. It's just that you don't need to put it in a local script. You just put the script in a text button.

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