This is my script: local button = script.Parent local name = script.Parent:WaitForChild("ElementName") local message = script.Parent.Parent.Parent.ChoiceFrame:WaitForChild("ConfirmationMessage") local frame = script.Parent.Parent.Parent:WaitForChild("OptionFrame") local sound = script.Parent:WaitForChild("Splash") local fire = script.Parent.Parent:WaitForChild("FlameReaper") local water = script.Parent.Parent:WaitForChild("Aqua") local earth = script.Parent.Parent:WaitForChild("EarthGuardian")
button.MouseButton1Down:connect(function() if frame.Visible == false then frame.Visible = true message.Text = "Are you sure you want to choose "..name.Value..", a Water type Element as your starter Element? Answer with ('Yes' or 'No')" if earth.Visible == true then earth.Visible = false if water.Visible == true then water.Visible = false if fire.Visible == true then fire.Visible = false end end end end end)
button.MouseEnter:connect(function() wait(0.2) sound:Play() sound.Volume = 0.5 wait(1) end)
button.MouseLeave:connect(function() wait(0.2) sound.Volume = 0 sound:Play() wait(1) end)
This is the error, help me fix it please I tried so many times no matter what I do it won't work ChoiceFrame is not a valid member of ScreenGui
To start, I recommend that, when posting your code, click on that "Lua Icon", above the area where you write your post, and put the code inside the set of "~" that just appeared, so it's easier to read your code.
About your error, what could've happened is that, you haven't waited until ChoiceFrame has loaded.
local choiceFrame = script.Parent.Parent.Parent:WaitForChild("ChoiceFrame") local message = choiceFrame:WaitForChild("ConfirmationMessage")
Small tip: I've noticed that your checking if the frames are visible, and if they are, set them to invisible:
if earth.Visible == true then earth.Visible = false if water.Visible == true then water.Visible = false if fire.Visible == true then fire.Visible = false end end end
You really don't need to check if they're visible.
If they are visible, and set it to invisible, they will become invisible.
If they are invisible, and set it to invisible, then they will continue invisible.
This is just a small tip so you consume less time writing your code, and in the end, make a more efficient and clean code.
local button = script.Parent local name = script.Parent:WaitForChild("ElementName") local choiceFrame = script.Parent.Parent.Parent:WaitForChild("ChoiceFrame") local message = choiceFrame:WaitForChild("ConfirmationMessage") local frame = script.Parent.Parent.Parent:WaitForChild("OptionFrame") local sound = script.Parent:WaitForChild("Splash") local fire = script.Parent.Parent:WaitForChild("FlameReaper") local water = script.Parent.Parent:WaitForChild("Aqua") local earth = script.Parent.Parent:WaitForChild("EarthGuardian") button.MouseButton1Down:connect(function() if frame.Visible == false then --Set frame to visible frame.Visible = true --Show players the message message.Text = "Are you sure you want to choose "..name.Value..", a Water type Element as your starter Element? Answer with ('Yes' or 'No')" --Hide the player's element Guis earth.Visible = false water.Visible = false fire.Visible = false end end) button.MouseEnter:connect(function() wait(0.2) sound:Play() sound.Volume = 0.5 wait(1) end) button.MouseLeave:connect(function() wait(0.2) sound.Volume = 0 sound:Play() wait(1) end)
Simple there is either nothing in your ScreenGUI named "frame" if there is something named "Frame" capitalize the F in your script. to lowercase it in your Game.StarterGUI.ScreenGUI and you should see Frame if not then insert it.