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)
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)
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.
4 comments
you're making little sense rn, you just use the variable Folder?
from a seperate script
Use GetPlayerFromCharacter on the the touched part’s parent. Then just find the folder normally.
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.