Is it possible to access a player's backpack from Workspace?
COMMUNITY QUESTION
Can I access a certain player's backpack from Workspace?
1 answer
Yes it is
local hasFlag = true
local function accessBackpack(hit)
if hit and hit.Parent then
local char = hit.Parent
local player = game.Players:GetPlayerFromCharacter(char)
local backpack = player:FindFirstChild("Backpack")
local flag = backpack:FindFirstChild("Flag")
local hum = char:FindFirstChild("Humanoid")
-- I don't know what you will be doing later on
if flag and flag.Parent == backpack and hasFlag == true then
-- Code here
elseif flag and flag.Parent == game:GetService("ServerStorage") and hasFlag == false then
-- Code here
end
end
end
accessBackpack()
This discussion is preserved as it was. New answers, comments, and votes are closed.

31 comments
So what is happening is: you know the last script you helped me with? Well it only works if this certain part is in the player's hand. I want it so that i can have an or statement that checks if the part is in their hand or backpack.
if char.Parent:FindFirstChild("RedFlag") or then --if they die and they have the flag. Right between the or and then is where the backpack thing is supposed to go.
Easy!
hmm
This is not very easy for me XD
Can you do it?
Yes
Ok, great!
So... hopefully this should be what you wanted
Well, I don't really want the person to drop the flag. I just want a check to see if the part is in their backpack.
I have done that
Wait a sec
ok
Fixed it
so i just put this right after the or and before the then?
What do you mean??
When I paste it in there, a red line appears below local
Which local??
There are too many locals
Which local??
nvm I fixed that. Now the output is saying that line 4 'hit' is a nil value
22:54:59.985 - Workspace.RedFlagSet.Script:4: attempt to index local 'hit' (a nil value)
Lemme fix that
Fixed!
Can I invite you to my roblox studio project? Because this is not working. XD
I could really use your help
Ok.
You can send link
ok
I sent you a friend request
Sorry I have to go