So, I’m trying to make a little bar at the bottom of your screen, which contains buttons that open different guis when clicked. In the main game, they work and all. However, I’m making an event for my game, which takes you to a different place within the experience. There, the bar only contains one button: to teleport to other parts of the map. However, for some odd reason, the button works indefinitely at first, but after respawning/dying/resetting, the button doesn’t function anymore, and the following error shows up in the console: “main_display is not a valid member of ScreenGui “challenges_gui” - Client - LocalScript:26”
Here is the script that I use:
local btn = script.Parent
local frame = script.Parent.Parent
local ui = script.Parent.Parent.Parent
local stroke = script.Parent.Parent.UIStroke
local TS = game:GetService("TweenService")
local TI = TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local TIclick = TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, true)
local goalGuiOpen = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("challenges_gui")
btn.MouseEnter:Connect(function()
TS:Create(frame, TI, {Position = UDim2.new(0.05, 0, 0, 0)}):Play()
TS:Create(stroke, TI, {Thickness = 3}):Play()
end)
btn.MouseLeave:Connect(function()
TS:Create(frame, TI, {Position = UDim2.new(0.05,0,0.04,0)}):Play()
TS:Create(stroke, TI, {Thickness = 0}):Play()
end)
btn.MouseButton1Down:Connect(function()
TS:Create(frame, TIclick, {Position = UDim2.new(0.05,0,0.04,0)}):Play()
TS:Create(stroke, TIclick, {Thickness = 0}):Play()
end)
btn.MouseButton1Click:Connect(function()
goalGuiOpen.main_display.Visible = not goalGuiOpen.main_display.Visible
end)
I have absolutely 0 idea as to what could be wrong, because in the main game, everything works…
The goalGuiOpen.main_display
IS LOCATED CORRECTLY. Here is a screenshot:
Any help is highly appreciated as I’m already very late with this event.