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

Storage not valid member of ServerStorage?

Storage is a folder I made to organize in server storage. Whenever I press play or join the game. The script says: "Storage is not valid member of ServerStorage" when I double-checked it's there and its there. But when I press play its not there :/ help!

local open = false

local clonetutorial = game:GetService("ServerStorage").Storage.GUI.Tutorial:Clone()
clonetutorial.Parent = game.Players.LocalPlayer.PlayerGui

local ui = game.Players.LocalPlayer.PlayerGui.Tutorial
script.Parent.MouseButton1Click:Connect(function()
	
		ui.Frame:TweenPosition(UDim2.new(0.334, 0,0.716, 0))
		
		wait(0.4)
		
		ui.Frame.Label.LocalScript.Disabled = false
		
end)

1 answer

This most likely due to an attempt to reference the Instance through an immediate variable declaration; the Script runs faster than the Server can actually load the assets within the game, this you must compensate for.

You can use two popular functions of Instance to tell the program how to retrieve and handle the Instance you with to store within a variable

local Part = workspace:FindFirstChild("Part")

FindFirstChild will attempt to retrieve the object as a child of workspace, if it cannot find it, it'll return nil and continue forth instead of throwing an exception

local Part = workspace:WaitForChild("Part")

WaitForChild will yield the Script until the given object exists (wait for it); this is the method you should use, as it'll ensure the object can be found, and is valid.


APPLYING THIS FIX TO YOUR PROGRAM
local ServerStorage = game:GetService("ServerStorage")
local Gui = ServerStorage:WaitForChild("Gui")

local Player = game:GetService("Players").LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
Gui:WaitForChild("Tutorial"):Clone().Parent = PlayerGui

local TutorialNew = PlayerGui:FindFirstChild("PlayerGui")

local Button = script.Parent
local Open = false
Button.MouseButton1Click:Connect(function()

        TutorialNew.Frame:TweenPosition(UDim2.new(0.335, 0,0.715, 0))
		--[[ .5 Scale on XY positions to center-screen if you 
		wish to do this. Otherwise, ensure you keep floats centered
		or rounded
		]]

        wait() --// wait yields for a default of .3mS

        TutorialNew.Frame.Label.LocalScript.Disabled = false

end)

Remember, don't forget to accept this answer if it helps!

2 comments

0

I will add the script so you can see what i'm working with.

0

@XxWingKing this is the solution

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