Tool is not a valid member of replicatedStorage?

I have folders in replicated storage, it goes Items > Food, Equipment, and Props. I have the vitamin tool inside the food section but for some reason it says its not a valid member, I cant post this entire script because its over 400 lines long but this is the main area of the script (Mostly the viewport variable. Thank you for your time.

		local Viewport =  ViewportUtil.Create(ToolModel[x.Name], "Tool")
		Viewport.AnchorPoint = Vector2.new(0.5,0.5)
		Viewport.Position = UDim2.fromScale(0.5, 0.5)
		Viewport.Size = UDim2.fromScale(1.5, 1.5)
		Viewport.Parent = Slot.Frame
	elseif x.TextureId ~= "" then
		Slot.Frame.TextLabel:Destroy()
		Slot.Frame.Icon.Image = x.TextureId
	else
		Slot.Frame.Icon:Destroy()
		Slot.Frame.TextLabel.Text = string.sub(x.Name, 1, 2)
	end
2 Likes

Try this when making a variable for the tool:
local rStorage = game:GetService("ReplicatedStorage")
and if it is a LocalScript:

local items = rStorage:WaitForChild("Items")
local food = items:WaitForChild("Food")
local vitaminTool = food:WaitForChild("Name") --edit this line for the tool
2 Likes

I forgot to tell you this is a custom hotbar system so that cant work besides maybe the first 2 variables, sorry I didnt say that

1 Like

I’m not entirely sure why that couldn’t work, it’s just looking for the names. Can you give a bit more context?

2 Likes

It didnt fix it : ( I also have a module called viewport util which the error fetched: Requested module experienced an error while loading The one I just showed right now had the error of: Vitamins is not a valid member of Tool “ReplicatedStorage.Assets.Items.Food.Vitamins”

2 Likes

The viewport Util is:

local Module = {}

local Origin = CFrame.new()
local White = Color3.new(1,1,1)
local LightDirection = Vector3.new(1,1,1)

local function UpdateCamera(Size, Center,Camera)
	local MaxSize = math.sqrt(Size.X^2 + Size.Y^2 + Size.Z^2)
	local Depth = MaxSize / math.tan(math.rad(Camera.FieldOfView))
	
	Camera.CFrame = CFrame.new(Center.X, Center.Y, Center.Z - Depth) * CFrame.Angles(0, math.pi, 0)
	Camera.Focus = Origin
end

function Module.Create(Object)
	Object = Object:Clone()
	
	local Frame = Instance.new("ViewportFrame")
	local Camera = Instance.new("Camera")
	local Size = nil
	local Center = nil
	
	if Object:IsA("BasePart") then
		Object:ClearAllChildren()
		Object.CFrame = Object.CFrame.Rotation
		Size = Object.Size
		Center = Object.CFrame
		else
		Object:PivotTo(Object:GetPivot().Rotation)
		Size = Object:GetExtentsSize()
		Center = Object:GetBoundingBox()
	end
		Camera.FieldOfView = 20
		UpdateCamera(Size, Center, Camera)
		Object.Parent = Frame
		Camera.Parent = Frame
		
		Frame.Ambient = White
		Frame.LightColor = White
		Frame.LightDirection = LightDirection
		Frame.BackgroundTransparency = 1
		
		Frame.SizeConstraint = (Size.X > Size.Y) and Enum.SizeConstraint.RelativeXX or Enum.SizeConstraint.RelativeYY
		Frame.CurrentCamera = Camera
		return Frame
end

return Module

The variables for the custom hotbar is:

local Players = game:GetService("Players")
local ReplicatedStorage =  game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")

local ViewportUtil = require(script.ViewportUtil)

local PropAssets = ReplicatedStorage.Assets.Items:WaitForChild("Prop")
local FoodAssets = ReplicatedStorage.Assets.Items:WaitForChild("Food")
local EquipmentAssets = ReplicatedStorage.Assets.Items:WaitForChild("Equipment")

local Player = Players.LocalPlayer
local PlayerGUI = Player.PlayerGui
local Mouse = Player:GetMouse()

local BackpackGUI = PlayerGUI:WaitForChild("HotbarUI")
local Hotbar = BackpackGUI.Inventory
local Default = Hotbar.Default

local GenerateIcons = true
local MaxNormalSlots = 5
local MaxReservedSlots = 0
Hotbar:SetAttribute("NormalMax", MaxNormalSlots)
Hotbar:SetAttribute("ReservedMax", MaxReservedSlots)

local White = Color3.new(1,1,1)
local Gold = Color3.new(1, 1, 0)
local Black = Color3.new(0,0,0)

local TweenData = {
	["Pop"] = TweenInfo.new(0.2, Enum.EasingStyle.Back),
	["Long"] = TweenInfo.new(0.2)
}

local OpaqueWhiteImage = {ImageTransparency = 0, ImageColor3 = White}
local OpaqueWhiteFrame = {BackgroundTransparency = 0, BackgroundColor3 = White}
local OqaqueGold = {BackgroundColor3 = Gold}
local TranslucentBlack = {ImageTransparency = 0.5, ImageColor3 = Black}
local SlotCreated = {Size = UDim2.fromScale(1, 1)}

local Backpack = nil
local Character = nil
local Humanoid = nil

local Slots = table.create(MaxNormalSlots + MaxReservedSlots)
local Tools = table.create(MaxNormalSlots + MaxReservedSlots)

local Locked = false
local Equipped = nil
local LastTool = nil
local Left, Right = nil, nil
local MouseListener = nil
1 Like

hhhhElllllllo???30charlimit

1 Like

Sorry, I can’t think why that’s not working right now. I’ll let you know if I think of anything.

1 Like

Studio is always randomly complicated I had an error about an adornee being nil a few days ago and it wasn’t even nil!!

1 Like

Make any adjustments if needed.

local toolModel = ToolModel[x.Name]

if toolModel then
    local Viewport = ViewportUtil.Create(toolModel, "Tool")
    Viewport.AnchorPoint = Vector2.new(0.5, 0.5)
    Viewport.Position = UDim2.fromScale(0.5, 0.5)
    Viewport.Size = UDim2.fromScale(1.5, 1.5)
    Viewport.Parent = Slot.Frame
else
    warn("Tool not found in ReplicatedStorage.")
end
2 Likes

for some reason it still didnt work, this is so weird.