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

Objects not allowed in hierarchy of GUI?

I am trying to copy a GUI from a brick to a player. In means of trying to keep it modular, being able to easily change values without going through scripts, I am using int values and string values. In studio my script works, however in online mode the output window is telling me that the values I'm trying to access in the script isn't a valid member of the GUI? I have other values that are found that are attached to buttons and frames, but the two that are directly under GUI have been causing me problems. Do I have to relocate them in the hierarchy to be in a frame?

--current

local button = script.Parent
local selectedClass = script.Parent.Parent.Parent.PreviewGui:WaitForChild("SelectedClass")--SelectedClass.Value
local selectedChar = script.Parent.Parent.Parent.PreviewGui:WaitForChild("SelectedChar")
local thisClass = script.Parent.Parent.Int.Value
local thisChar = script.Parent.Parent.Title.Value


function MouseOver()
	local sound = Instance.new("Sound")
	sound.SoundId = "http://www.roblox.com/asset?id=341970310"
	sound.Volume = 1
	sound.Pitch = 1
	sound.Parent = game.Players.LocalPlayer.PlayerGui
	sound:Play()
	wait()
	sound:remove()
end
--

function onClicked()

	--Play a sound
	local sound = Instance.new("Sound")
	sound.SoundId = "http://www.roblox.com/asset?id=341992923"
	sound.Volume = 10
	sound.Pitch = 1
	sound.Parent = game.Players.LocalPlayer.PlayerGui
	sound:Play()
	wait()
	sound:remove()
	--Pick the Class
	selectedClass.Value = tostring(thisClass)
	selectedChar.Value = tostring(thisChar) --thisChar

	end

function getName()
	local findName = script.Parent.Parent.Title.Value -- a class type of StringValue within the overall Frame
	return findName	
end

print("getName() is "..getName())
script.Parent.Text = getName()
script.Parent.MouseEnter:connect(MouseOver)
button.MouseButton1Click:connect(onClicked)

2 comments

0

Include specifics. What's the exact error? What code is that error complaining about?

0

The Dev Console says that "SelectedValues is not a valid member of ScreenGui"

1 answer

The problem I was having was related to using LocalScript over Script.

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