Ad
Log in to vote
0

[SOLVED] Backpack is not a valid member of model?

Asked by 2 months ago
Edited 2 months ago
workspace.Dispenser.Gui.SurfaceGui.Frame.TextButton1.MouseButton1Down:Connect(function()
local Cup = workspace.Dispenser.Box2
local Handle = workspace.Dispenser:WaitForChild('Handle') -- "Handle" assumed to already be in Workspace
local player = game.Players.LocalPlayer.Character


print('LOADED CUP')
    for i = 1,10 do
        Handle.Transparency = Handle.Transparency - 0.1
        wait(0.1)
    end
    workspace.Sound:Play()
    wait(3)
    Handle.Transparency = 1
    local NewCup = game.ServerStorage.Coffee:Clone()
    NewCup.Handle.CFrame = Cup.CFrame
    NewCup.Parent = player.Backpack
    print (NewCup.Parent)
end) -- Rewritten

When I try to run this code via LocalScript, all it prints in the output when I try to clone the item to the player's backpack is, "Backpack is not a valid member of model". I've had this problem in the past and have no idea why it happens. Also the LocalScript is placed inside StarterCharacterScripts, too.

0
Also if you are going to comment, "Try WaitForChild" it either doesn't work or I'm putting it in the wrong place. MustangHeart -2 — 2mo
0
You get the backpack from the LocalPlayer, not their Character lol. And ServerStorage is inaccessible by clients, move your objects to ReplicatedStorage. incapaz 6717 — 2mo
0
Thank you so much dude! Please post your comment as an answer so I can give you the best answer! MustangHeart -2 — 2mo
0
it's fine. Edit your title so it contains [SOLVED], it marks the question as answered and let's others know the problem has been solved. incapaz 6717 — 2mo

Answer this question