Hello developers!
Basically I’m trying to get all the parts shown here with this little script I made! It functions but only returns the first name, which is “1”.
Heres my code, but I need it to work with all of them, but it only returns the first value.
local UIS = game:GetService("UserInputService")
local key = Enum.KeyCode.E
--local UI = game.ServerStorage:WaitForChild("EToInteract")
local StudsAway = 15
local HRP = game.Players.LocalPlayer.Character:WaitForChild('HumanoidRootPart')
local playerInteracted = game.ReplicatedStorage:WaitForChild("PlayerInteracted")
local db = false
local function getAllInteractions()
for i,v in pairs(workspace.E_Interactions:GetDescendants()) do
if v:IsA('BasePart') and v.Name == 'E_Main' then
return v
end
end
end
-- Main
UIS.InputBegan:Connect(function(input, isPlayerTyping)
if input.KeyCode == key and isPlayerTyping == false and db == false then
--if (getAllInteractions().Position - HRP.Position).magnitude < StudsAway then
print(getAllInteractions().Parent.Name)
--end
end
end)
Thanks!