How would I go about getting this remotevent to work?

I have a remote event set up I just need to get it to fire here. I’ve tried getting onplayeradded but for some reason this keeps it from recognizing getinstanceswitid and player anyway, as well as requiring an end and I can’t get that to fix anything. I am really not sure what to do about this

local TransitionEvent = ReplicatedStorage:WaitForChild("TransitionEvent")
local getInstancesWithID = function(ID)
	local returnValue = {};

	for _, i in pairs(game:GetDescendants()) do
		pcall(function()
			if(i:GetAttribute("ID") == ID) then table.insert(returnValue, i) end; 
		end);
	end;

	return returnValue;
end;

for _, h in pairs(getInstancesWithID("Teleporter")) do
	if(h:IsA("BasePart")) then 
		h.Touched:Connect(function(hit)
			--TransitionEvent:FireClient()
			local Pos = h.Destination.Value
			wait(1)
			hit.parent:moveTo(Pos.Position)
			
		end)
	end;
end;```