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

How do i acess a folder inside a player using a touched event?

so what I did was

game.Players.PlayerAdded:Connect(function(plr)
Folder = Instance.new('Folder')
Folder.Parent = plr

--But now i want to acess the folder from a touch event but I dont know how
from a seperate script 
end)

4 comments

0

you're making little sense rn, you just use the variable Folder?

0

from a seperate script

1

Use GetPlayerFromCharacter on the the touched part’s parent. Then just find the folder normally.

0

If it's a script running whenever someone touches it, (Server side maybe?), Get the player who touches it, do "somevariable = plr:WaitForChild("foldername")", then just use that variable to acess the folder. Nothing too complicated. Albeit if it's from a local script, you can just call localplayer to find it instead.

1 answer

I'm going to assume you're using a local script for the Touched event.

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Part = workspace:WaitForChild("LookPart")
local Debounce = false -- You don't need this

Part.Touched:Connect(function(TouchingPart)
	if not Debounce and TouchingPart.Parent == Character then
		Debounce = true
		local Folder = Player:FindFirstChild("Folder") -- Here.
	end
end)

This question was weird altogether and there's a better way to go about what you're doing.

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