Tag Unable To Cast Value To Objects

I Used The Tag Plugin And I Need Help

image

--// Services
local Workspace = game:GetService("Workspace")
local CollectionService = game:GetService("CollectionService")
local TaggedParts = CollectionService:GetTags("Portal")

--// Objects
local Portal = game.Workspace.Builds.Portals:WaitForChild("Portal")
local PortalCost = Portal:WaitForChild("Cost")
local TouchPortal = game.Workspace.Builds.Portals.Portal.PortalDoor


for _, TaggedParts in pairs(TaggedParts) do
	TaggedParts.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then

			print(PortalCost.Value)

		end
	end)
end

In line 4, instead of GetTags, use GetTagged.

Also here you can change the first letter of TaggedParts -or some letter else- so it won’t get complicated.

for _, taggedParts in pairs(TaggedParts) do
	taggedParts.Touched:Connect(function(hit)
	    if hit.Parent:FindFirstChild("Humanoid") then
            print(PortalCost.Value)
        end
    end)
end
1 Like