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

How do you fix ServerStorage is not a valid member of DataMode error?

I have a problem with this script;

local button = script.Parent
local HatchingFrame = script.Parent.Parent.Parent:WaitForChild("HatchingMoment")
local HatchedImage = script.Parent.Parent:WaitForChild("HatchedImage")
local HatchedName = script.Parent.Parent:WaitForChild("Name")
local Slot1 = game.Players.LocalPlayer.PlayerGui.MenuGui.InventoryMain.InventoryFrame.InventoryBackground:WaitForChild("ElementSlot1")
local Image = game.Players.LocalPlayer.PlayerGui.MenuGui.InventoryMain.InventoryFrame.InventoryBackground.ElementSlot1:WaitForChild("ElementImage")
local amount = game.Players.LocalPlayer.PlayerGui.MenuGui.InventoryMain.InventoryFrame.InventoryBackground.ElementSlot1.ElementImage:WaitForChild("Amount")
local element = game.Players.LocalPlayer.PlayerGui.EggSellGui.MainFrame.ShopFrame.BuggyEgg:WaitForChild("Element")
local slot1currentimage = game.Players.LocalPlayer.PlayerGui.MenuGui.InventoryMain.InventoryFrame.InventoryBackground.ElementSlot1.ElementImage:WaitForChild("CurrentImage")
local purpleterriaimage = game.ServerStorage.PurpleTerria:WaitForChild("Image")
local purpleterrianame = game.ServerStorage.PurpleTerria:WaitForChild("Name")

button.MouseButton1Down:connect(function()
	if HatchingFrame.Visible == true then 
		HatchingFrame.Visible = false
		button.Visible = false
		HatchedImage.Image = ""
		HatchedName.Text = ""
		if element.Value == "Purple Terria" then
			Slot1.Visible = true
			wait(0.1)
			slot1currentimage.Value = purpleterriaimage.Value
			wait(0.1)
			Image.Image = slot1currentimage.Value
			amount:WaitForChild("NumberAmount").Value = amount:WaitForChild("NumberAmount").Value + 1
		end
	end
end)

Error says; ServerStorage is not a valid member of DataMode

So in the script this line has an error;

local purpleterriaimage = game.ServerStorage.PurpleTerria:WaitForChild("Image")

Any idea how to fix? Error on line 10, please help!

1 answer

✓ Accepted answer

Use ReplicatedStorage instead. ServerStorage isn't visible to LocalScripts.

A better solution would probably be to keep it where it is and utilize RemoteFunctions/Events so that the client doesn't ever have direct access to something that other clients access. But for simple games or tests, ReplicatedStorage is fine.

2 comments

0

I don't know what RemoteFunctions/Events are but I will try ReplicatedStorage

0

They're super useful for dealing with server/client interactions. I changed it to a link in my post.

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