Item not going into backpack

I’m very new to scripting and as practice I’m trying to make a shop system but I’m having a problem with making it so when the player clicks the item it goes into their backpack, does anyone know the solution? I’ve read posts about using parameters but I’m not very good at Implementing them. Here’s my code

image

image
You should do like this:

local Player = game.Players.LocalPlayer
local Redblock = script.Parent

RedBlock.ClickDetector.MouseButton1Click:Connect(function()
 Redblock.Parent = Player.Backpack
end)

This is a server script so I cant use local player that was the first thing I tried. I probably should have mentioned that

1 Like

Later on, this is a LocalScript you probably used. What you could’ve done instead is:

local RedBlock = script.Parent
local ClickDetector = RedBlock.ClickDetector

ClickDetector.MouseClick:Connect(function(Player)
	RedBlock.Parent = Player.Backpack
end)

In a Script, not a LocalScript.

I thought you were using a LocalScript at first.

Yea sry I edited the post to include that

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.