Is it possible to make a function on one local script, then have it work for multiple separate tagged items in the workspace. This is an interaction gui, by the way.
Example :
function Interaction(Frame, Action, ActionFrame, KeyFrame, Key, TaggedItems)
while wait() do
Frame.Visible = false
for _,item in pairs(TaggedItems) do
if (item.PrimaryPart.Position - game.Players.LocalPlayer.Character.PrimaryPart.Position).magnitude <= 6 and game.Players.LocalPlayer:GetMouse().Target == item.PrimaryPart then
Frame.Visible = true
ActionFrame.Text = Action
KeyFrame.Text = Key
break
end
end
end
end
Interaction() --Imagine I filled it out and everything
Interaction() --Now Imagine I filled it out with a different tag
This doesn’t work for some reason. I don’t want to write the same code and function block multiple times. Is there a less hacky way of doing this? Thank you.