ServerStorage is not a valid member of datamodel "Game"

image

hello, i get this error when i try refining serverstorage.

any help is appreciated

Probably want to decapitalize Game

Also, could we see the hierarchy?

In case the name has been changed somehow, you can/should use game:GetService("ServerStorage") to find services by their class name.

2 Likes

You cannot access ServerStorage from a LocalScript.
If you are using a LocalScript, have you tried using ReplicatedStorage instead?

Thanks for all responds,

any idea how i can convert this to a server script?

local ServerStorage = game:GetService("ServerStorage")

local Tools = ServerStorage.FireAxe

local LocalPlayer = game.Players.LocalPlayer

local Price = script.Parent.Parent.Price

local ItemName = script.Parent.Parent.ItemName

script.Parent.MouseButton1Click:connect(function()

if Price.Value <= LocalPlayer.leaderstats:FindFirstChild("Cash").Value and workspace.Shops_.Restock_.Melee_.Axe.Value >= 1 then

Tools.FireAxe:Clone().Parent = LocalPlayer.Backpack

game.ReplicatedStorage.ShopEvents.AxeBuy:FireServer(ItemName.Value)

script.Parent.Parent.Parent.Buy:Play()

script.Parent.Parent.Visible = false

end

end)

If the script is meant for handling user input on a GUI then it should be a local script. The server script that responds to your ‘AxeBuy’ event should be the one that adds the tool to the player’s backpack, not the local script.

1 Like

I think the problem is in the Local Script, I just don’t know how to locate the ServerStorage or the ServerScriptService from a LocalScript, I recommend that you better use a RemoteEvent and that you do the function you wanted with that
Edit: sorry, I hadn’t read everything

Do the following:

--LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local RemoteEvent = ReplicatedStorage["RemoteEvent"]["ShopEvents"]["AxeBuy"]

local Tools = ServerStorage.FireAxe

local LocalPlayer = game.Players.LocalPlayer

local Price = script.Parent.Parent.Price

local ItemName = script.Parent.Parent.ItemName

script.Parent.MouseButton1Click:connect(function()

if Price.Value <= LocalPlayer.leaderstats:FindFirstChild("Cash").Value and workspace.Shops_.Restock_.Melee_.Axe.Value >= 1 then

Tools.FireAxe:Clone().Parent = LocalPlayer.Backpack

RemoteEvent:FireServer(ItemName.Value, Price.Value)

script.Parent.Parent.Parent.Buy:Play()

script.Parent.Parent.Visible = false

end

end)
--Normal script
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local RemoteEvent = ReplicatedStorage["RemoteEvent"]["ShopEvents"]["AxeBuy"]

local Tools = ServerStorage.FireAxe

RemoteEvent.OnServerEvent:Connect(function(player, Item, Price)
--Here put what you want to do
end)

Don’t try to access server storage from a local script.
You don’t need to change it to replicated storage, either.
In the code you posted you appear to already be using a remote event. Put your server-dependent code in that event’s server-side handler.