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

How to fix not being able to detect when a TextButton is being clicked?

Asked by 3 years ago

I've been working on th GUI for my game during the past few days and recently one of the buttons has stopped working (nothing happens when pressed). I would like to know what is wrong in the LocalScript and how I can fix it, or what else might be causing it.

I've done some testing using print() statements and the origin of the problem seems to be that the LocalScript is not detecting when the button is being clicked.

Here are all the parts fo the LocalScript that involve the button + what I used find the souce of the error.

local PlayTypeSelection = script.Parent.MainMenu
local FreeroamSelect = PlayTypeSelection.GamemodeSelect.FreeroamFrame.FreeroamSelect
local StageSelectionFrame = script.Parent.StageSelectScreen
local function ToggleMapSelect()

    if StageSelectionFrame.Visible == false then

        StageSelectionFrame.Visible = true
        PlayTypeSelection:TweenPosition(UDim2.new(0,0,0.5,0))
        StageSelectionFrame:TweenPosition(UDim2.new(0.5,0,0.5,0))
        wait(0.9)
        PlayTypeSelection.Visible = false
    else

        PlayTypeSelection.Visible = true
        StageSelectionFrame:TweenPosition(UDim2.new(1.5,0,0.5,0))
        PlayTypeSelection:TweenPosition(UDim2.new(0.5,0,0.5,0))
        wait(0.9)
        StageSelectionFrame.Visible = false

    end
end
FreeroamSelect.MouseButton1Click:Connect(ToggleMapSelect)
FreeroamSelect.MouseButton1Click:Connect(function()
    print("this is not the source of the problem")
end)

the last bit of the script did't print anythhing

0
Additionally the LocalScript is inside a ScreenGUI and there is no error in the output Dinocrazy45 0 — 3y
0
Well, the Gui's Parent should always be in PlayerGui. PlayerGui is inside of "game.Players.[PlayerName].PlayerGui". If the problem is not the parent problem then, I don't know... Hope this help thank you! uiuiuiuihauahua67 15 — 3y
0
maybe have the script like local FreeroamSelect = PlayTypeSelection.GamemodeSelect.FreeroamFrame.FreeroamSelect instead of local FreeroamSelect =  *next    line* PlayTypeSelection.GamemodeSelect.FreeroamFrame.FreeroamSelect TheLegacyOfReaper 14 — 3y
0
why would you need to anyway? Persona3_FES 2 — 3y
0
Ok, I've tried to reference the button with PlayerGui but it still didn't work, I dont really understand whatis happening so I'll just remake the whole thing from scratch, anyways, thank you for trying to help, really appreaciate it! Dinocrazy45 0 — 3y

Answer this question