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

FindFirstChild and WaitForChild both doesn't work?

Asked by 6 years ago

Here we go. I'm creating a Menu GUI and I used the TweenService(?). More of that whenever I use WaitForChild or FindFirstChild on Line 2, both would, regardless, give me a warning and error, respectively. Help would be appreciated.

local btn = script.Parent
local service = game:GetService("ServerStorage")
local gui = service:WaitForChild("Gui")  --Infinite Yield Warning
local guion = false

function TweenGui()
    guion = true
    local newgui = gui:Clone()  --Error for FindFirstChild
    newgui.Parent = script.Parent.Parent.Parent
    local frame = newgui:WaitForChild("Frame")
    frame.Position = UDim2.new(-5,0,.5,0)
    frame:TweenPosition(UDim2.new(0.5,0,0.5,0), "In", "Linear" , 2)



end

function TweenBackGui()
    guion = false

    local newgui = script.Parent.Parent.Parent.Parent.PlayerGui.Gui

    local frame = newgui:WaitForChild("Frame")

    frame:TweenPosition(UDim2.new(-5,0,0.5,0), "In", "Linear" , 2)
    wait(5)
    frame.Parent:Destroy()



end

function GetStatus()
if guion == false then
    TweenGui()



else
    TweenBackGui()
end


end

script.Parent.MouseButton1Click:Connect(GetStatus)

Thanks!

0
Is Gui a child of ServerStorage? User#21908 42 — 6y
0
Yes. Syntax_404 37 — 6y
0
Make sure the gui is correctly named "Gui" or try naming it something else. MaxOutGaming -3 — 6y
0
Will try when I get home Syntax_404 37 — 6y
0
After doing some research I noticed that LocalScripts can't access ServerStorage. Problem Solved. Syntax_404 37 — 6y

1 answer

Log in to vote
0
Answered by 3 years ago

when you run the game everything in serverstorage gets deleted. use replicatedstorage

Ad

Answer this question