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.

4 comments

0

Also if you are going to comment, "Try WaitForChild" it either doesn't work or I'm putting it in the wrong place.

0

You get the backpack from the LocalPlayer, not their Character lol. And ServerStorage is inaccessible by clients, move your objects to ReplicatedStorage.

0

Thank you so much dude! Please post your comment as an answer so I can give you the best answer!

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.