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

Objects not allowed in hierarchy of GUI?

Asked by 8 years ago

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)

0
Include specifics. What's the exact error? What code is that error complaining about? BlueTaslem 18071 — 8y
0
The Dev Console says that "SelectedValues is not a valid member of ScreenGui" DaRtHSpeeDy 10 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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

Ad

Answer this question