Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can I access a certain player's backpack from Workspace?

Is it possible to access a 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()

31 comments

0

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.

0

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.

0

Easy!

0

hmm

0

This is not very easy for me XD

0

Can you do it?

0

Yes

0

Ok, great!

0

So... hopefully this should be what you wanted

0

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.

0

I have done that

0

Wait a sec

0

ok

0

Fixed it

0

so i just put this right after the or and before the then?

0

What do you mean??

0

When I paste it in there, a red line appears below local

0

Which local??

0

There are too many locals

0

Which local??

0

nvm I fixed that. Now the output is saying that line 4 'hit' is a nil value

0

22:54:59.985 - Workspace.RedFlagSet.Script:4: attempt to index local 'hit' (a nil value)

0

Lemme fix that

0

Fixed!

0

Can I invite you to my roblox studio project? Because this is not working. XD

0

I could really use your help

0

Ok.

0

You can send link

0

ok

0

I sent you a friend request

0

Sorry I have to go

This discussion is preserved as it was. New answers, comments, and votes are closed.